-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[5.5][Concurrency] Propagate Darwin vouchers across async tasks. #39160
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
[5.5][Concurrency] Propagate Darwin vouchers across async tasks. #39160
Conversation
Darwin OSes support vouchers, which are key/value sets that can be adopted on a thread to influence its execution, or sent to another process. APIs like Dispatch propagate vouchers to worker threads when running async code. This change makes Swift Concurrency do the same. The change consists of a few different parts: 1. A set of shims (in VoucherShims.h) which provides declarations for the necessary calls when they're not available from the SDK, and stub implementations for non-Darwin platforms. 2. One of Job's reserved fields is now used to store the voucher associated with a job. 3. Jobs grab the current thread's voucher when they're created. 4. A VoucherManager class manages adoption of vouchers when running a Job, and replacing vouchers in suspended tasks. 5. A VoucherManager instance is maintained in ExecutionTrackingInfo, and is updated as necessary throughout a Job/Task's lifecycle. rdar://76080222 (cherry picked from commit a80a19b)
@swift-ci please test |
Build failed |
Build failed |
…_LOG macro. This macro takes the string and parameters directly, and is conditionally defined to either call fprintf or ignore its arguments. This makes the call sites a little more pleasant (no #if scattered about) and ensures every log includes the thread ID and a newline automatically. (cherry picked from commit d5c0469)
@swift-ci please test |
…opt from the SDK.
@swift-ci please test |
Build failed |
Build failed |
Using has_include to conditionalize the stubbing of voucher_needs_adopt doesn't work when the SDK provides an older header that doesn't declare the function. Instead, always provide a stub, but use overload resolution to prefer the SDK's declaration. Declare the stub as taking `void *`. When calling it with `voucher_t`, the implicit conversion is allowed, but causes the overload to be disfavored when the SDK's declaration takes `voucher_t`. rdar://82797720
657b70c
to
601c29a
Compare
@swift-ci please test |
Build failed |
@swift-ci please test macos platform |
Cherry pick #39115 to
release/5.5
.Darwin OSes support vouchers, which are key/value sets that can be adopted on a thread to influence its execution, or sent to another process. APIs like Dispatch propagate vouchers to worker threads when running async code. This change makes Swift Concurrency do the same.
The change consists of a few different parts:
This cherry-pick also incorporates:
rdar://76080222