-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Fix env::ArgsOs
for zkVM
#139849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix env::ArgsOs
for zkVM
#139849
Conversation
r? @ibraheemdev rustbot has assigned @ibraheemdev. Use |
This PR fixes the iterator, but leaves the arg retrieval and copying the same. There are some interesting alternatives to be considered there. rust/library/std/src/sys/args/zkvm.rs Lines 21 to 38 in 2da29db
It looks like the memory allocated by As for the comment about reimplementing |
I've now implemented the caching approach. The two commits are complete fixes with different approaches, so they should be considered separately until we decide. |
☔ The latest upstream changes (presumably #140581) made this pull request unmergeable. Please resolve the merge conflicts. |
The zkVM implementation of `env::ArgsOs` incorrectly reports the full length even after having iterated. Instead, use a range approach which works out to be simpler. Also, implement more iterator methods like the other platforms in rust-lang#139847.
Retrieve argc/argv from the host once, on demand when the first `env::ArgsOs` is constructed, and globally cache it. Copy each argument to an `OsString` while iterating.
I think we'd like to test this out somehow before accepting this. It doesn't look like it will cause a problem, but I'm not entirely sure. |
Triage: ping @thaliaarchi , any update on adding tests for this? |
@Enselic Oh, I had interpreted @flaub's comment differently 😅. I thought "we'd like to test this" meant zkVM maintainers would run the existing Disappointingly, the only tests for Aside from the general lack of tests, specific to this PR, there are two new tests that would be useful: Testing that the length is reported correctly while iterating (fixed in the first commit). This could be a new test for all platforms and I wouldn't mind adding this. And testing that successive constructions of the iterators will return the same args, since the host could theoretically non-deterministically return different args (fixed in the second commit). I have no idea how to setup this test for zkVM or whether it's a threat model worth considering. |
@Enselic Given the approval by a target maintainer, I think this is ready now |
Ping @ibraheemdev (see comment right above) |
@bors r+ rollup |
☀️ Test successful - checks-actions |
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing 5d1b897 (parent) -> 4645a79 (this PR) Test differencesShow 4 test diffs4 doctest diffs were found. These are ignored, as they are noisy. Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard 4645a7988177c286f61609cc667ecae4c571a2e8 --output-dir test-dashboard And then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
Finished benchmarking commit (4645a79): comparison URL. Overall result: ✅ improvements - no action needed@rustbot label: -perf-regression Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 9.3%, secondary 3.7%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary -0.7%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 471.616s -> 471.629s (0.00%) |
The zkVM implementation of
env::ArgsOs
incorrectly reports the full length even after having iterated. Instead, use a range approach which works out to be simpler. Also, implement more iterator methods like the other platforms in #139847.cc @flaub @jbruestle @SchmErik