-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Emit #[inline] on derive(Debug) #117727
Emit #[inline] on derive(Debug) #117727
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Emit #[inline] on derive(Debug) Breaking out part of rust-lang#116583 (comment) r? `@ghost`
This comment was marked as outdated.
This comment was marked as outdated.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
857e13c
to
a317db1
Compare
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Emit #[inline] on derive(Debug) Breaking out part of rust-lang#116583 (comment) r? `@ghost`
This comment has been minimized.
This comment has been minimized.
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (bd37a3c): 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 sizeResultsThis 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.
Bootstrap: 663.159s -> 673.479s (1.56%) |
I suspect that the speedup is for a very simple reason: |
In that case I think what we want is to only mono the function downstream, but not have it marked as inline by LLVM. Instead of inlining should we experiment something like |
Inlining is still at LLVM's discretion, all this attribute does is apply the It does a lot. I am not sure to what degree all these effects are separable, but we're having this conversation because I am studying separating the codegen style and MIR inlining from the LLVM attribute and inferring the non-inlinehint effects. If you want to have a broader conversation about this we should do that outside this PR, maybe on Zulip, but in my opinion we are primarily short on information to feed a useful discussion. |
@nnethercote My hypothesis here is that it's a happy consequence of the move to |
Actually, one thing that puzzles me: how does this make a bunch of check builds so much faster? What are those check builds doing that cares enough about inlining of these things to show up? Naïvely I'd have though it would be impossible for inlining to matter for things like check that don't do codegen (or even optimized MIR, right?). The usual possibility of "oh well it make rustc faster" feels like it can't possibly be the answer since I can't imagine that |
☀️ Test successful - checks-actions |
Finished benchmarking commit (0f44eb3): comparison URL. Overall result: ❌✅ regressions and improvements - ACTION NEEDEDNext Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression Warning ⚠: The following benchmark(s) failed to build:
cc @rust-lang/wg-compiler-performance 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 sizeResultsThis 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.
Bootstrap: 662.531s -> 673.197s (1.61%) |
Improvements outweigh regressions. And the big regression looks spurious, probably related to the collector slowness that started a few days ago. |
Would it be worth trying to only apply this attribute to structs with at most 5 fields, but not enums or larger structs? Those are exactly the ones where the body will be just a single function call. |
…-debug, r=<try> Try not applying #[inline] to big structs Per rust-lang#117727 (comment) r? `@ghost`
I tried: #118031 (comment) and it's a huge regression. So I suspect the dead code effect and the MIR optimization effects are both important here. |
Interesting... Thanks for trying!
|
To be clear the `#[inline]` does not hint that inlining is beneficial, but it does give the compiler the option to inline if the compiler things it would be beneficial. This starts adding the `#[inline]` attribute to: 1. `IsVariant`: it's expected that this is often beneficial since its body is tiny. 2. `Debug`: This is to stay in line with the `std` implementation of the `Debug` derive. rust-lang/rust#117727 It also explicitely doesn't add the attribute to the methods of `Error`, since those are almost never called in hot code paths. Fixes #317
To be clear the `#[inline]` does not hint that inlining is beneficial, but it does give the compiler the option to inline if the compiler things it would be beneficial. This starts adding the `#[inline]` attribute to: 1. `IsVariant`: it's expected that this is often beneficial since its body is tiny. 2. `Debug`: This is to stay in line with the `std` implementation of the `Debug` derive. rust-lang/rust#117727 It also explicitely doesn't add the attribute to the methods of `Error`, since those are almost never called in hot code paths. Fixes #317
To be clear, the `#[inline]` does not hint that inlining is beneficial, but it does give the compiler the option to inline if the compiler things it would be beneficial. This starts adding the `#[inline]` attribute to: 1. `IsVariant`: it's expected that this is often beneficial, since its body is tiny. 2. `Debug`: This is to stay in line with the `std` implementation of the `Debug` derive. rust-lang/rust#117727 It also explicitly doesn't add the attribute to the methods of `Error`, since those are almost never called in hot code paths.
Update Rust toolchain from nightly-2023-11-09 to nightly-2023-11-10 without any other source changes. This is an automatically generated pull request. If any of the CI checks fail, manual intervention is required. In such a case, review the changes at https://github.com/rust-lang/rust from rust-lang@fdaaaf9 up to rust-lang@0f44eb3. The log for this commit range is: rust-lang@0f44eb32f1 Auto merge of rust-lang#117727 - saethlin:inline-derived-fmt, r=nnethercote rust-lang@eae4135939 Auto merge of rust-lang#117708 - onur-ozkan:x-setup, r=clubby789 rust-lang@4c8862b263 Auto merge of rust-lang#117122 - ferrocene:pa-configure-git-diff, r=albertlarsan68 rust-lang@d32d9238cf Emit #[inline] on derive(Debug) rust-lang@b7583d38b7 Auto merge of rust-lang#117712 - lcnr:expand-coroutine, r=jackh726 rust-lang@488dd9bc73 fmt rust-lang@e7998aa21f Auto merge of rust-lang#117734 - nnethercote:rm-Zstrip, r=davidtwco rust-lang@287ae4db75 Auto merge of rust-lang#117632 - Nilstrieb:icup, r=davidtwco rust-lang@492e57c6ad Auto merge of rust-lang#117736 - TaKO8Ki:rollup-fjrtmlb, r=TaKO8Ki rust-lang@d1e26401bc chore(bootstrap): capitalize {error, warning, info, note} tags rust-lang@42fbf3ebf5 allow users to override the existing configuration during x setup rust-lang@3d6417fc7a check config file before prompts on x setup rust-lang@f5195c52bb Rollup merge of rust-lang#117724 - Kobzol:shim-error-message, r=onur-ozkan rust-lang@e603f4491c Rollup merge of rust-lang#117723 - onur-ozkan:keep-bootstrap-on-x-clean, r=albertlarsan68 rust-lang@6533c62ce7 Rollup merge of rust-lang#117705 - tshepang:patch-2, r=Nilstrieb rust-lang@b4fa5b7004 Rollup merge of rust-lang#117694 - jmillikin:core-io-borrowed-buf, r=m-ou-se rust-lang@4cc549811f Rollup merge of rust-lang#117645 - compiler-errors:auto-trait-subst, r=petrochenkov rust-lang@a1a8d6fe9c Rollup merge of rust-lang#116762 - WaffleLapkin:fixup_fromptr_docs, r=RalfJung rust-lang@d8dbf7ca0e Auto merge of rust-lang#117557 - Zoxc:panic-prio, r=petrochenkov rust-lang@ecc936b155 Remove `-Z strip`. rust-lang@57fb1e643a Auto merge of rust-lang#117454 - shepmaster:github-actions-m1-tests, r=GuillaumeGomez,onur-ozkan rust-lang@341c85648c Move `BorrowedBuf` and `BorrowedCursor` from `std:io` to `core::io` rust-lang@92267c9794 update mir-opt tests rust-lang@992d93f687 rename `BorrowKind::Shallow` to `Fake` rust-lang@a42eca42df generator layout: ignore fake borrows rust-lang@622be2d138 Restore rustc shim error message rust-lang@de0458af97 speed up `x clean` rust-lang@6909992501 Run tests in CI for aarch64-apple-darwin rust-lang@64090536d4 Install tidy for aarch64-apple-darwin rust-lang@469d34b39b Mark Rustdoc test as Linux-only rust-lang@bf360d407e instrument constituent types computation rust-lang@03435e6fdd accept review suggestion rust-lang@769ad29c3e triagebot.toml: use inclusive language rust-lang@102384523a Document how rust atomics work wrt mixed-sized and non-atomic accesses rust-lang@c17d33f1df Extend builtin/auto trait args with error when they have >1 argument rust-lang@580fa0c1a9 rename github_repository to git_repository rust-lang@ffffc2038f Update ICU4X rust-lang@ff1858e2aa Make `FatalErrorMarker` lower priority than other panics rust-lang@4a0873533f update suggest-tests rust-lang@5a562d962e pass the correct args to compiletest rust-lang@545cc830e1 allow configuring the parent GitHub repository Co-authored-by: celinval <[email protected]>
To be clear, the `#[inline]` does not hint that inlining is beneficial, but it does give the compiler the option to inline if the compiler things it would be beneficial. This starts adding the `#[inline]` attribute to: 1. `IsVariant`: it's expected that this is often beneficial, since its body is tiny. 2. `Debug`: This is to stay in line with the `std` implementation of the `Debug` derive. rust-lang/rust#117727 It also explicitly doesn't add the attribute to the methods of `Error`, since those are almost never called in hot code paths.
While working on #116583 I noticed that the
cross_crate_inlinable
query identifies a lot of derivedDebug
impls as a MIR body that's little more than a call, which suggests they may be a good candidate for#[inline]
. So here I've implemented that change specifically.It seems to provide a nice improvement to build times.