-
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
Avoid adding builtin functions to symbols.o
#118568
Conversation
r? @davidtwco (rustbot has picked a reviewer for you, use r? to override) |
r? @bjorn3 cc @nnethercote We probably can perform a performance test. |
This comment has been minimized.
This comment has been minimized.
5886ba0
to
80b756c
Compare
This comment has been minimized.
This comment has been minimized.
|
80b756c
to
bd662ce
Compare
The Miri subtree was changed cc @rust-lang/miri |
I moved |
symbols.o
symbols.o
bd662ce
to
afaa906
Compare
@@ -110,7 +110,8 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap<S | |||
// We have to preserve the symbols of the built-in functions during LTO. | |||
let is_builtin_fn = is_compiler_builtins | |||
&& symbol_export_level(tcx, def_id.to_def_id()) | |||
.is_below_threshold(SymbolExportLevel::C); | |||
.is_below_threshold(SymbolExportLevel::C) | |||
&& name.contains("compiler_builtins"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should check the name here. The compiler-builtins crate may have a different name. Maybe check for #[no_mangle]
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's better.
It would be good to do a perf run on CI before this is merged, to confirm the expected perf effects. |
afaa906
to
063071d
Compare
This comment has been minimized.
This comment has been minimized.
063071d
to
ca0738f
Compare
Could you do this for me? I don't have perf permissions. |
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Avoid adding builtin functions to `symbols.o` We found performance regressions in rust-lang#113923. The problem seems to be that `--gc-sections` does not remove these symbols. I tested that lld removes these symbols, but ld and gold do not. I found that `used` adds symbols to `symbols.o` at https://github.com/rust-lang/rust/blob/3e202ead604be31f4c1a5798a296953d3159da7e/compiler/rustc_codegen_ssa/src/back/linker.rs#L1786-L1791. The PR removes builtin functions. Note that under LTO, ld still preserves these symbols. (lld will still remove them.) The first commit also fixes rust-lang#118559. But I think the second commit also makes sense.
@DianQK You can always ask for a perf run https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/perf.20run which will probably be faster than hoping someone sees a GitHub comment. I mean, maybe it won't for you, since your work attracts so many eyes. But in general, the Zulip topic is pretty quck. |
Thanks. I saved this stream. :) |
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (3a9fb17): comparison URL. Overall result: ✅ improvements - no 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. @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: 672.674s -> 673.359s (0.10%) |
@bors r+ |
☀️ Test successful - checks-actions |
Finished benchmarking commit (503e129): 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.
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: 675.63s -> 675.646s (0.00%) |
…enkov Revert rust-lang#113923 Per [#t-compiler/meetings > [weekly] 2024-01-11](https://rust-lang.zulipchat.com/#narrow/stream/238009-t-compiler.2Fmeetings/topic/.5Bweekly.5D.202024-01-11) discussion, revert rust-lang#113923. Also revert associated rust-lang#118568. The PR rust-lang#113923 causes the regression issue rust-lang#118609. We need more time to find a proper solution. Discussions start at [412365838](https://rust-lang.zulipchat.com/#narrow/stream/238009-t-compiler.2Fmeetings/topic/.5Bweekly.5D.202024-01-11/near/412365838) and continue to [412369643](https://rust-lang.zulipchat.com/#narrow/stream/238009-t-compiler.2Fmeetings/topic/.5Bweekly.5D.202024-01-11/near/412369643). Fixes rust-lang#118609. r? compiler
Rollup merge of rust-lang#119885 - DianQK:revert-pr-113923, r=petrochenkov Revert rust-lang#113923 Per [#t-compiler/meetings > [weekly] 2024-01-11](https://rust-lang.zulipchat.com/#narrow/stream/238009-t-compiler.2Fmeetings/topic/.5Bweekly.5D.202024-01-11) discussion, revert rust-lang#113923. Also revert associated rust-lang#118568. The PR rust-lang#113923 causes the regression issue rust-lang#118609. We need more time to find a proper solution. Discussions start at [412365838](https://rust-lang.zulipchat.com/#narrow/stream/238009-t-compiler.2Fmeetings/topic/.5Bweekly.5D.202024-01-11/near/412365838) and continue to [412369643](https://rust-lang.zulipchat.com/#narrow/stream/238009-t-compiler.2Fmeetings/topic/.5Bweekly.5D.202024-01-11/near/412369643). Fixes rust-lang#118609. r? compiler
[beta] Revert rust-lang#113923 Per [#t-compiler/meetings > [weekly] 2024-01-11](https://rust-lang.zulipchat.com/#narrow/stream/238009-t-compiler.2Fmeetings/topic/.5Bweekly.5D.202024-01-11) discussion, revert rust-lang#113923. Also revert associated rust-lang#118568. The PR rust-lang#113923 causes the regression issue rust-lang#118609. We need more time to find a proper solution. Discussions start at [412365838](https://rust-lang.zulipchat.com/#narrow/stream/238009-t-compiler.2Fmeetings/topic/.5Bweekly.5D.202024-01-11/near/412365838) and continue to [412369643](https://rust-lang.zulipchat.com/#narrow/stream/238009-t-compiler.2Fmeetings/topic/.5Bweekly.5D.202024-01-11/near/412369643). Fixes rust-lang#118609. Same as rust-lang#119885 but backported to beta. r? compiler
We found performance regressions in #113923. The problem seems to be that
--gc-sections
does not remove these symbols. I tested that lld removes these symbols, but ld and gold do not.I found that
used
adds symbols tosymbols.o
atrust/compiler/rustc_codegen_ssa/src/back/linker.rs
Lines 1786 to 1791 in 3e202ea
The PR removes builtin functions.
Note that under LTO, ld still preserves these symbols. (lld will still remove them.)
The first commit also fixes #118559. But I think the second commit also makes sense.