-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Add -Z panic-in-drop={unwind,abort} command-line option #88759
Conversation
r? @estebank (rust-highfive has picked a reviewer for you, use r? to override) |
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 75b61d15a9d844666c07d09064bec26a595d83fd with merge 1f815a30705b7e96c149fc4fa88a98ca04e2deee... |
This comment has been minimized.
This comment has been minimized.
☀️ Try build successful - checks-actions |
Queued 1f815a30705b7e96c149fc4fa88a98ca04e2deee with parent c9db3e0, future comparison URL. |
Finished benchmarking commit (1f815a30705b7e96c149fc4fa88a98ca04e2deee): comparison url. Summary: This change led to large relevant mixed results 🤷 in compiler performance.
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. Benchmarking 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 led 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 |
Could we make it a hard error if there's a mismatch in this between crates? |
Where would be the best place to add this check? Do we have any precedent for validating crate compatibility? |
I think there is a similar check here: rust/compiler/rustc_metadata/src/dependency_format.rs Lines 391 to 418 in c5cbf78
|
This shaves 5MB off |
75b61d1
to
9f45cee
Compare
9f45cee
to
b70bafe
Compare
This looks really promising! I think this would be a good first step. Before we can even consider changing the default behavior, we'd need to have an option for the new behavior, and experiment with it extensively. |
Can somebody else in @rust-lang/compiler take this review on? I am not as confident in codegen as the rest of the compiler. |
r? @nagisa cc @nikic @wesleywiser |
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.
LGTM so far, but I'd like to review test changes once the drop_in_place
lang item isn't spuriously required, which seems to account for a lot of them.
Another thing to add on a quick skim: in MIR when building cleanup blocks, we spend a lot of effort to build unwind ladders just in case a cleanup/drop panics. All of that can also be disabled when this flag is enabled, potentially giving you another significant perf boost in build times. |
b70bafe
to
037b216
Compare
I've addressed all the review feedback. I'm having a bit of trouble wrapping my head around the drop tree building code, so I haven't made any changes there yet. |
037b216
to
5862a00
Compare
Addressed feedback. |
panic_in_drop: PanicStrategy = (PanicStrategy::Unwind, parse_panic_strategy, [TRACKED], | ||
"panic strategy for panics in drops"), |
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.
Add accepted values list and default (like in some other options), plus maybe unstable book entry?
@bors r=nagisa,eddyb I think this is reasonable starting point. I suspect there are more places we can reduce the amount of work we do, but there's no reason for all that to be covered in this specific PR. |
📌 Commit 5862a00 has been approved by |
☀️ Test successful - checks-actions |
Finished benchmarking commit (51e514c): comparison url. Summary: This benchmark run did not return any relevant changes. If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression |
Now, I use "-Zpanic-in-drop=abort" and
Anybody knows how to resolve it? |
It seems to work fine for me:
|
This PR changes
Drop
to abort if an unwinding panic attempts to escape it, making the process abort instead. This has several benefits:Drop
is very unintuitive and easy to miss: unwinding continues, but the remaining drops in scope are simply leaked.syn
).One thing to note about
-Z panic-in-drop=abort
is that all crates must be built with this option for it to be sound since it makes the compiler assume that droppingBox<dyn Any>
will never unwind.cc rust-lang/lang-team#97