-
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
Add ParallelGuard
type to handle unwinding in parallel sections
#115144
Conversation
(rustbot has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
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.
r=me with or without
/// continuing with unwinding. It's also used for the non-parallel code to ensure error message | ||
/// output match the parallel compiler for testing purposes. | ||
pub struct ParallelGuard { | ||
panic: Lock<Option<Box<dyn Any + std::marker::Send + 'static>>>, |
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.
Should we implement Drop
for ParallelGuard
to make sure we never drop a panic on the floor without handling it? unwind
will need to get reworked below if so.
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 initially went for Drop
, but I ended up preferring the explicit unwinding of the unwind
calls.
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 think having the explicit unwind calls is better. I just wonder if we should protect against missing unwind calls somehow... anyways, I don't feel particularly strongly about it.
@bors delegate+ |
✌️ @Zoxc, you can now approve this pull request! If @compiler-errors told you to " |
📌 Commit d0a3e77e7b4c4c787451780e8abeb3eab4ec4353 has been approved by It is now in the queue for this repository. |
I've changed to the |
Thanks! |
resume_unwind(panic); | ||
} | ||
let guard = ParallelGuard::new(); | ||
let r = t.into_iter().filter_map(|i| guard.run(|| map(i))).collect(); |
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.
Wouldn't this non-deterministically pick one of the panics if multiple happen? For FatalErrorMarker
that is fine as it is a ZST, but for other panics it may not be.
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 see why that would be problematic. No panic would be guaranteed to "win" in a concurrent setting. FatalErrorMarker
is the only exception (not technically a panic) that we need to handle.
I've changed this to use a function taking a closure, that way unwinding is guaranteed to be done if needed. |
@Zoxc I think you have to r=reviewer again |
I think the changes is significant enough to warrant a re-review. @rustbot ready |
@bors r+ |
📌 Commit 9074443d3f84d7f7ae5e110f6f92100ddf8c344f has been approved by It is now in the queue for this repository. |
☔ The latest upstream changes (presumably #111713) made this pull request unmergeable. Please resolve the merge conflicts. |
☀️ Test successful - checks-actions |
Finished benchmarking commit (59a8294): 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 sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 630.996s -> 633.863s (0.45%) |
This adds a
ParallelGuard
type to handle unwinding in parallel sections instead of manually dealing with panics in each parallel operation. This also adds proper panic handling to thejoin
operation.cc @SparrowLii