-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Remove a large amount of leb128-coded integers #119791
Conversation
100% of the serialized enums during libcore compilation fit into the smaller tag, and this eliminates hitting the leb128 code for coding/decoding when we can statically guarantee that's not required. 30% of all leb128 integers serialized in libcore (12981183 total) come from the usize's removed here.
This removes emit_enum_variant and the emit_usize calls that resulted in. In libcore this eliminates 17% of leb128, taking us from 8964488 to 7383842 leb128's serialized.
r? @cjgillot (rustbot has picked a reviewer for you, use r? to override) |
This comment was marked as resolved.
This comment was marked as resolved.
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Remove a large amount of leb128-coded integers This removes ~41%[^1] of the leb128-encoded integers serialized during libcore compilation by changing enum tags to opportunistically use `u8` where feasible instead of the leb128 coding via `usize`. This should have effectively zero impact on metadata file sizes, since almost all or all enum tags fit into the 7 bits available in leb128 for single-byte encodings, but my hope (as yet untested) is that this is a win for compilation times (by eliminating branches, if predictable ones) and possibly compiler's code size (via more branch elimination). [^1]: More than half the remaining integers still fit into <= 128, so the leb128 coding still makes sense. 32% are zero, and 46% are <= 4.
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (78bd79d): comparison URL. Overall result: ❌✅ regressions and improvements - ACTION NEEDEDBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 667.55s -> 665.141s (-0.36%) |
Seems like this is pretty much neutral on everything except bootstrap times, presuming the delta there isn't noise. I think we should move ahead with it though. |
@bors r+ |
☀️ Test successful - checks-actions |
Finished benchmarking commit (68acb39): comparison URL. Overall result: ✅ improvements - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 666.77s -> 665.325s (-0.22%) |
|
This removes ~41%1 of the leb128-encoded integers serialized during libcore compilation by changing enum tags to opportunistically use
u8
where feasible instead of the leb128 coding viausize
.This should have effectively zero impact on metadata file sizes, since almost all or all enum tags fit into the 7 bits available in leb128 for single-byte encodings. Perf results indicate this is basically neutral across the board except for an improvement in bootstrap time.
Footnotes
More than half the remaining integers still fit into <= 128, so the leb128 coding still makes sense. 32% are zero, and 46% are <= 4. ↩