-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Simplify num formatting helpers #143540
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
Simplify num formatting helpers #143540
Conversation
Thanks, let's run perf. @bors2 try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Simplify num formatting helpers Noticed `ilog10` was being open-coded when looking at this diff: https://github.com/rust-lang/rust/pull/143423/files/85d6768f4c437a0f3799234df20535ff65ee17c2..76d9775912ef3a7ee145053a5119538bf229d6e5#diff-6be9b44b52d946ccac652ddb7c98146a01b22ea0fc5737bc10db245a24796a45 That, and two other small cleanups 😁 (should probably go through perf just to make sure it doesn't regress formatting)
Regardless of what perf winds up saying, I'm not sure about this; code size is about the same but you lose the early returns and add memory access https://rust.godbolt.org/z/sdejK8T9M. imo "flat" is the best of the three since the source is more readable and it has a smaller best-case icount than the other options. |
Thanks for putting this into godbolt! rust/library/core/src/num/int_log10.rs Lines 31 to 34 in 8e61502
|
Yeah, from that godbolt link the ilog10 variant looks obviously best to me. If it wasn't, the u16 ilog10 impl should probably be rewritten! All three functions have very similar code size, none access memory, so all the difference is in branches and data dependency structure. Singling out the best case icount seems misleading, since there's no reason to expect the FWIW, the AArch64 codegen has virtually no branches in |
I am skeptical of more complicated and nuanced "simplifications" but usually |
I stand very corrected here; I was thinking this would be more predictable, and read the brackets without looking closely (why does lea use that syntax...). No objection! |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (44935f5): comparison URL. Overall result: no relevant changes - no action neededBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. @bors rollup=never Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results (primary 2.6%, secondary -5.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary -6.2%, secondary 6.3%)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: 460.528s -> 460.41s (-0.03%) |
@bors r+ |
☀️ 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 45b80ac (parent) -> 040e2f8 (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 040e2f8b9ff2d76fbe2146d6003e297ed4532088 --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 (040e2f8): comparison URL. Overall result: ❌✅ regressions and 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 3.6%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 3.1%, secondary 4.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (secondary -0.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 467.247s -> 467.351s (0.02%) |
The perf improvement is just noise, right? |
…t, r=tgross35 Simplify num formatting helpers Noticed `ilog10` was being open-coded when looking at this diff: https://github.com/rust-lang/rust/pull/143423/files/85d6768f4c437a0f3799234df20535ff65ee17c2..76d9775912ef3a7ee145053a5119538bf229d6e5#diff-6be9b44b52d946ccac652ddb7c98146a01b22ea0fc5737bc10db245a24796a45 That, and two other small cleanups 😁 (should probably go through perf just to make sure it doesn't regress formatting)
Noticed
ilog10
was being open-coded when looking at this diff: https://github.com/rust-lang/rust/pull/143423/files/85d6768f4c437a0f3799234df20535ff65ee17c2..76d9775912ef3a7ee145053a5119538bf229d6e5#diff-6be9b44b52d946ccac652ddb7c98146a01b22ea0fc5737bc10db245a24796a45That, and two other small cleanups 😁
(should probably go through perf just to make sure it doesn't regress formatting)