-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Adjust inlining attributes around panic_immediate_abort #104999
Conversation
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
I don't think we want to change runtime things for the non- |
Based on some of your prompting elsewhere I think I have found other opportunities for tweaks along these lines. I want to run those down then decide if they belong in here. |
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit 5b0baa9614a34329e90f08b8f70a5df86425be45 with merge 17e1dcef1c425dbbe0e2f0d4f6f1fcf962d1cc90... |
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (17e1dcef1c425dbbe0e2f0d4f6f1fcf962d1cc90): comparison URL. Overall result: no relevant changes - 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 benchmark run did not return any relevant results for this metric. Max RSS (memory usage)This benchmark run did not return any relevant results for this metric. CyclesThis benchmark run did not return any relevant results for this metric. |
5b0baa9
to
906c360
Compare
@rustbot ready |
LGTM, thanks. @bors r+ |
⌛ Testing commit 906c360 with merge 96c520d2784be83c65edcec5d87bb5dde74b1a6e... |
💔 Test failed - checks-actions |
The job Click to see the possible cause of the failure (guessed by this bot)
|
@thomcc The failure looks like some kind of network-related flake to me? Maybe I'm just grasping because I don't understand how this could cause any issues. Can you retry? |
@bors retry |
☀️ Test successful - checks-actions |
Finished benchmarking commit (32e613b): 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)This benchmark run did not return any relevant results for this metric. CyclesThis benchmark run did not return any relevant results for this metric. |
…=thomcc Adjust inlining attributes around panic_immediate_abort The goal of `panic_immediate_abort` is to permit the panic runtime and formatting code paths to be optimized away. But while poking through some disassembly of a small program compiled with that option, I found that was not the case. Enabling LTO did address that specific issue, but enabling LTO is a steep price to pay for this feature doing its job. This PR fixes that, by tweaking two things: * All the slice indexing functions that we `const_eval_select` on get `#[inline]`. `objdump -dC` told me that originally some `_ct` functions could end up in an executable. I won't pretend to understand what's going on there. * Normalize attributes across all `panic!` wrappers: use `inline(never) + cold` normally, and `inline` when `panic_immediate_abort` is enabled. But also, with LTO and `panic_immediate_abort` enabled, this patch knocks ~709 kB out of the `.text` segment of `librustc_driver.so`. That is slightly surprising to me, my best theory is that this shifts some inlining earlier in compilation, enabling some subsequent optimizations. The size improvement of `librustc_driver.so` with `panic_immediate_abort` due to this patch is greater with LTO than without LTO, which I suppose backs up this theory. I do not know how to test this. I would quite like to, because I think what this is solving was an accidental regression. This only works with `-Zbuild-std` which is a cargo flag, and thus can't be used in a rustc codegen test. r? `@thomcc` --- I do not seriously think anyone is going to use a compiler built with `panic_immediate_abort`, but I wanted a big complicated Rust program to try this out on, and the compiler is such.
The goal of
panic_immediate_abort
is to permit the panic runtime and formatting code paths to be optimized away. But while poking through some disassembly of a small program compiled with that option, I found that was not the case. Enabling LTO did address that specific issue, but enabling LTO is a steep price to pay for this feature doing its job.This PR fixes that, by tweaking two things:
const_eval_select
on get#[inline]
.objdump -dC
told me that originally some_ct
functions could end up in an executable. I won't pretend to understand what's going on there.panic!
wrappers: useinline(never) + cold
normally, andinline
whenpanic_immediate_abort
is enabled.But also, with LTO and
panic_immediate_abort
enabled, this patch knocks ~709 kB out of the.text
segment oflibrustc_driver.so
. That is slightly surprising to me, my best theory is that this shifts some inlining earlier in compilation, enabling some subsequent optimizations. The size improvement oflibrustc_driver.so
withpanic_immediate_abort
due to this patch is greater with LTO than without LTO, which I suppose backs up this theory.I do not know how to test this. I would quite like to, because I think what this is solving was an accidental regression. This only works with
-Zbuild-std
which is a cargo flag, and thus can't be used in a rustc codegen test.r? @thomcc
I do not seriously think anyone is going to use a compiler built with
panic_immediate_abort
, but I wanted a big complicated Rust program to try this out on, and the compiler is such.