-
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
Implement -Z oom=panic #88098
Implement -Z oom=panic #88098
Conversation
r? @kennytm (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 97c23fdb1834d1669314cc73b3b31a9cb451e28a with merge 14b72f38ec9756851f7af637cd45f181890e3bd7... |
This comment has been minimized.
This comment has been minimized.
☀️ Try build successful - checks-actions |
Queued 14b72f38ec9756851f7af637cd45f181890e3bd7 with parent 0035d9d, future comparison URL. |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking try commit (14b72f38ec9756851f7af637cd45f181890e3bd7): comparison url. Summary: This change led to moderate 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 perf run, please indicate this with @bors rollup=never |
There seems to be no impact on performance and binary size increases by only 0.1%, so I think we can simply remove The only remaining issue is deciding how we should expose the ability to have OOM unwind to users:
|
I think benchmarking compiler is not very relevant here. Std's microbenchmarks should give more meaningful results. |
I disagree, the compiler is a great benchmark because it makes a lot of memory allocations as part of the compilation process (usually through |
This issue documented the binary size blowup that happened the first time they started allowing unwinding on oom: #42808. We should do all the same checks they did to make sure we're not reintroducing the same issues. |
I ran the same tests: on the serde one the size increase was only 0.8%, on the In conclusion I think this is an entirely reasonable tradeoff for allowing OOM to be handled in user code. |
That's a surprisingly small overhead. I am uncertain if there are any code currently assuming that handle_alloc_error won't unwind though, since |
One particular worry is that |
You're right, the drop isn't getting called in this example: #![feature(box_syntax)]
use std::panic::catch_unwind;
struct Foo;
impl Drop for Foo {
fn drop(&mut self) {
println!("Foo dropped");
}
}
fn main() {
catch_unwind(|| {
let foo = Foo;
let a = box [0u8; 1024*1024*1024];
let b = box [0u8; 1024*1024*1024];
let c = box [0u8; 1024*1024*1024];
let d = box [0u8; 1024*1024*1024];
println!("No oom");
});
println!("Caught unwind!");
} I'm not sure how difficult it would be to make |
I think rust/library/alloc/src/alloc.rs Line 392 in a49e38e
C-unwind as abi.
Edit: |
⌛ Testing commit 0254e31 with merge a8f752f012f12dbeff295ee772d568ebc1d9b08a... |
💔 Test failed - checks-actions |
@bors retry Waiting on getting CI working. |
@bors treeclosed- |
☀️ Test successful - checks-actions |
Finished benchmarking commit (d6f3a4e): comparison url. Summary: This benchmark run did not return any relevant results. If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression |
Implement -Z oom=panic This PR removes the `#[rustc_allocator_nounwind]` attribute on `alloc_error_handler` which allows it to unwind with a panic instead of always aborting. This is then used to implement `-Z oom=panic` as per RFC 2116 (tracking issue rust-lang#43596). Perf and binary size tests show negligible impact.
Implement -Z oom=panic This PR removes the `#[rustc_allocator_nounwind]` attribute on `alloc_error_handler` which allows it to unwind with a panic instead of always aborting. This is then used to implement `-Z oom=panic` as per RFC 2116 (tracking issue rust-lang#43596). Perf and binary size tests show negligible impact.
… r=oli-obk Stabilize default_alloc_error_handler Tracking issue: rust-lang#66741 This turns `feature(default_alloc_error_handler)` on by default, which causes the compiler to automatically generate a default OOM handler which panics if `#[alloc_error_handler]` is not provided. The FCP completed over 2 years ago but the stabilization was blocked due to an issue with unwinding. This was fixed by rust-lang#88098 so stabilization can be unblocked. Closes rust-lang#66741
… r=oli-obk Stabilize default_alloc_error_handler Tracking issue: rust-lang#66741 This turns `feature(default_alloc_error_handler)` on by default, which causes the compiler to automatically generate a default OOM handler which panics if `#[alloc_error_handler]` is not provided. The FCP completed over 2 years ago but the stabilization was blocked due to an issue with unwinding. This was fixed by rust-lang#88098 so stabilization can be unblocked. Closes rust-lang#66741
This PR removes the
#[rustc_allocator_nounwind]
attribute onalloc_error_handler
which allows it to unwind with a panic instead of always aborting. This is then used to implement-Z oom=panic
as per RFC 2116 (tracking issue #43596).Perf and binary size tests show negligible impact.