-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 unnecessary abstractions from option and result impls #81747
Conversation
r? @sfackler (rust-highfive has picked a reviewer for you, use r? to override) |
FWIW there were a couple of PRs recently that did the exact opposite (inside the compiler), for example #81084 |
Changes in the standard library reduce the amount of necessary codegen for everyone using the standard library, and for each instantiation in each code generation unit (when method is marked inline). @bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 0e1bc1f0a89e5257063c2c4cf2df417ced15c86f with merge 8af8326194c1c86d79c90ab07f97bd831dda7c57... |
☀️ Try build successful - checks-actions |
Queued 8af8326194c1c86d79c90ab07f97bd831dda7c57 with parent e708cbd, future comparison URL. |
Yeah my point was mostly to make sure that this is not ping-ponged between the two variants, and that the costs of the combinator functions is clear (possible clearer code vs. compilation time). |
Finished benchmarking try commit (8af8326194c1c86d79c90ab07f97bd831dda7c57): comparison url. Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up. @bors rollup=never |
It's important to actually measure the impact on llvm-lines, because the results are very often surprising. I did that, and the results are negligible. The standard library went from 338978 total llvm lines up to 339051. That's +73. Personally, I still like these changes, since it makes the implementation easier to understand. Commands, for reference:
|
Wow, thanks for checking that. The Alas, using your methodology I obtained a reduction of 65 lines (355936 before, and 355871 after). I repeated measurement twice to check if the numbers are reproducible and they are. Though, as above, I don't think those numbers are meaningful. BTW. Those changes are about functions like EDIT: Using no-opt.bc, I measured a reduction of 1357 lines (1209870 before, 1208513 after). Commands for reference: env RUSTFLAGS="-Csave-temps" ./x.py clean
env RUSTFLAGS="-Csave-temps" ./x.py build --stage 0 library/std
for f in ./build/x86_64-unknown-linux-gnu/stage0-std/x86_64-unknown-linux-gnu/release/deps/*.no-opt.bc; do
./build/x86_64-unknown-linux-gnu/llvm/bin/llvm-dis "$f";
done
cargo-llvm-lines llvm-lines --files ./build/x86_64-unknown-linux-gnu/stage0-std/x86_64-unknown-linux-gnu/release/deps/*.ll |
OT but catched my eye.
Are you sure this is the case? Is it written somewhere? I haven't found it mentioned in the docs, but it could explain a lot of confusing behaviour I (and others) encountered when using If that's the case, would it make sense to update |
Yes. With a caveat that |
Thanks, that makes sense. I forgot about |
@rustbot label: -S-waiting-on-review +S-waiting-on-author |
Change the implementation of a option and result methods to avoid code generation of additional functions, where a simple match is sufficient.
@rustbot label: +S-waiting-on-review -S-waiting-on-author |
r? @m-ou-se |
Considering rust-timer didn't show any improvement and the llvm lines also barely changed, what's the remaining motivation for this change? |
While rebasing I also noticed that one of methods had been changed already, since in the proposed form it can be easier to turn it into a const fn. Otherwise, at this point, I think it mostly awaits decision on whether to merge it or not. Thanks. @rustbot label: +S-waiting-on-review -S-waiting-on-author |
In that case I'm closing this. Of all of the changes, I only think the one for |
Change the implementation of a option and result methods
to avoid code generation of additional functions, where
a simple match is sufficient.