-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[Concurrency] Correct enqueue behavior in with... functions by adopting nonisolated(nonsending) #80753
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?
Conversation
de601db to
1303d99
Compare
|
This is blocked by incorrect behavior of the caller execution on a closure rdar://149107104 |
a583630 to
9ea3293
Compare
|
Now blocked on rdar://150017382 |
|
@swift-ci please smoke test |
|
@swift-ci smoke test |
1 similar comment
|
@swift-ci smoke test |
|
Good news, this was now unblocked by #82858 |
25a963e to
be2b2ad
Compare
|
@swift-ci please smoke test |
|
This is almost unblocked, we need to fix throwing nonisolated nonsending (caller isolated) closures to not lose isolation -- rdar://155313349 And there seems to be a problem with noncopyable types and nonisolated nonsending (caller isolated) closures as well; It shows up in Giving it a run to see if anything else |
|
@swift-ci please smoke test |
|
By now this is unlikely to make it into 6.2.0 |
9f1e063 to
0e5a262
Compare
|
@swift-ci please smoke test |
|
Fixing all the ABI tests to follow. |
fcdc60b to
01e0397
Compare
01e0397 to
9a2d287
Compare
|
@swift-ci please smoke test |
This is the minimal set of changes from swiftlang#80753 to specifically address the with...Continuation APIs re-enqueueing tasks when they need not have to. Resolves rdar://162192512 resolves
|
@gottesmm will investigate the optimizer approach to solving this instead; seems we're missing the optimization in debug mode |
This is the minimal set of changes from swiftlang#80753 to specifically address the with...Continuation APIs re-enqueueing tasks when they need not have to. In the specific case of the continuation APIs we move to adopt the `nonisolated(nonsending)` feature, however there will be a follow-up here to improve how we handle enqueues with a Serial Executor that is also a Task Executor at the same time Resolves rdar://162192512
This is the minimal set of changes from swiftlang#80753 to specifically address the with...Continuation APIs re-enqueueing tasks when they need not have to. In the specific case of the continuation APIs we move to adopt the `nonisolated(nonsending)` feature, however there will be a follow-up here to improve how we handle enqueues with a Serial Executor that is also a Task Executor at the same time Resolves rdar://162192512
This is the minimal set of changes from swiftlang#80753 to specifically address the with...Continuation APIs re-enqueueing tasks when they need not have to. In the specific case of the continuation APIs we move to adopt the `nonisolated(nonsending)` feature, however there will be a follow-up here to improve how we handle enqueues with a Serial Executor that is also a Task Executor at the same time Resolves rdar://162192512
This is the minimal set of changes from swiftlang#80753 to specifically address the with...Continuation APIs re-enqueueing tasks when they need not have to. In the specific case of the continuation APIs we move to adopt the `nonisolated(nonsending)` feature, however there will be a follow-up here to improve how we handle enqueues with a Serial Executor that is also a Task Executor at the same time Resolves rdar://162192512
9a2d287 to
3ceae73
Compare
|
@swift-ci please smoke test |
jamieQ
left a comment
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.
some further unsolicited feedback/questions for your consideration :)
| func globalTestFunc(isolation: isolated (any Actor)? = #isolation) async { | ||
| isolation!.assertIsolated("wat in \(#function)!") | ||
| await withTaskCancellationHandler { | ||
| isolation!.assertIsolated("wat in \(#function)!") |
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.
might be good to test that this works without a capture of the isolated parameter too, to ensure it's relying on the nonisolated(nonsending)-ness of the closure, and not the isolated capture logic.
eda5dc2 to
aa0fb44
Compare
This drastically lessens the number of unexpected task enqueues and hops that these APIs cause, and therefore improves performance and even correctness in a few cases (like the withContinuation APIs)
aa0fb44 to
13e6b40
Compare
|
@swift-ci please smoke test |
The problem is that even with the #isolation parameter the non-Sendable
async closure operation still would potentially hop off the caller
isolation. We introduced this change because the plan was the
non-Sendable closure would run on the isolated parameter's isolation,
but that's not actually the case: an "re-enqueue" can still happens in those cases.
Instead, we can use the nonisolated(nonsending) on the function and closure,
in order to guarantee there is no hop between those at all, and
developers can trust that adding this cancellation handler will not
cause any unexpected isolation changes and hops.
The API was always documented to not hop as we execute the operation,
so this brings the correct and expected behavior.
This corrects the following APIs:
as well as task group's next() and related ones...
This gets down the "re-enqueue" count of those methods by far, and makes all these more reliable and predictable.
resolves rdar://140110775
resolves rdar://162192512