-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[Concurrency] Prevent task re-enqueues in continuation APIs #84944
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
base: main
Are you sure you want to change the base?
[Concurrency] Prevent task re-enqueues in continuation APIs #84944
Conversation
|
@swift-ci please smoke test |
|
The release/debug modes was a bit misleading and we should fix that as well tbh, since it did complete hop elimination. but it did HIDE the real issue actually. The real issue is in the enqueue and run methods, and I feel like we talked about this but we never fixed it... I'll fix up the tests tomorrow. |
ea36b2d to
50f7d5b
Compare
50f7d5b to
9c96b6c
Compare
This explicitly adopts nonisolated nonsending funcs for the with continuation APIs. This guarantees there are not spurious enqueues between the caller and the closure executing, which is a requirement for these methods. This takes a risk on removing the bad #isolation based API from source, however explicitly passing the isolation as something else than the actual isolation would always have been incorrect, so we should try to get this through. There are further re-enqueue fixes to be done, but this specific API should adopt the nonisolated nonsending approach. Resolves rdar://162192512
9c96b6c to
13c453b
Compare
| @unsafe | ||
| public func withUnsafeThrowingContinuation<T>( | ||
| isolation: isolated (any Actor)? = #isolation, | ||
| public nonisolated(nonsending) func withUnsafeThrowingContinuation<T>( |
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 hope we can get away with this "technically" source break... Let's see what the source compat suite says.
|
@swift-ci please smoke test |
|
@swift-ci please smoke test |
|
@swift-ci please test source compatibility |
|
@swift-ci please test source compatibility |
|
@swift-ci please smoke test |
|
@swift-ci please smoke test |
|
@swift-ci please smoke test macOS |
|
@swift-ci please smoke test Windows |
|
@swift-ci please test source compatibility |
|
The hummingbird issue in release mode seems unrelated to this change. |
|
#85062 has landed, you should be able to drop the workaround commits now |
This is the minimal set of changes from
#80753 to specifically address the with...Continuation APIs re-enqueueing tasks when they need not have to.
Resolves rdar://162192512
Before, 10 enqueues in total in the task executor case:
After, two total enqueues in the task executor: