Commit Graph

1607 Commits

Author SHA1 Message Date
Mike Ash
7427aa5f48 [Concurrency] Remove SWIFT_ENABLE_ASYNC_JOB_DISPATCH_INTEGRATION environment variable.
This option serves no purpose anymore and this dispatch integration should always be enabled.
2024-05-30 12:43:19 -04:00
Holly Borla
135e3f2ee9 Merge pull request #73889 from hborla/deprecate-anyactor
[Concurrency] Deprecate `AnyActor`.
2024-05-30 09:36:35 -07:00
Mykola Pokhylets
b5e039d1e0 Fixed 32-bit build with SWIFT_CONCURRENCY_ENABLE_PRIORITY_ESCALATION 2024-05-30 13:15:39 +02:00
Mykola Pokhylets
6298d41edf Reapply "Fix quadratic performance of the ListMerger in specific usage pattern"
This reverts commit 2640ff613b.
2024-05-30 13:08:42 +02:00
Holly Borla
c20b0e0956 [Concurrency] Obsolete AnyActor in Swift 6 using a typealias. 2024-05-29 22:59:19 -07:00
John McCall
a8d163bb23 Merge pull request #73966 from rjmccall/condvar-await-scope
Fix a bug with task-to-thread continuations
2024-05-29 18:56:51 -04:00
Mike Ash
d0ed6f6ba2 Merge pull request #73945 from mikeash/dispatch-async-swift-job-no-dlsym
[Concurrency] Reference dispatch_async_swift_job directly when the header is available.
2024-05-29 14:25:55 -04:00
John McCall
d3e7b5116f In the task-to-thread model of UnsafeContinuation, destroy the
condvar before we try to tail-call.  This is necessary because the
swiftasync tail-call handling is (reasonably) reluctant to reorder
cleanups so that locals are destroyed before the call, and of course it
cannot destroy them after it and still emit a tail call.

Old versions of clang handled these tailcalls differently and failed
to diagnose this, but I'm pretty sure they just ended up not doing a
tail call rather than actually doing anything reasonable.

Fixes rdar://125363169
2024-05-28 22:04:50 -04:00
Konrad `ktoso` Malawski
a664c02f60 Merge pull request #73934 from ktoso/pick-concurrency-isCurrent-more-fixes 2024-05-29 10:07:53 +09:00
Mike Ash
c396f75792 [Concurrency] Reference dispatch_async_swift_job directly when the header is available.
Only use dlsym when we don't have the header, since it's an unnecessary performance hit.

rdar://118465481
2024-05-28 17:35:39 -04:00
Alex Lorenz
57b89d5303 [android] add an android NDK Swift overlay module, and use it instead of Glibc 2024-05-28 12:57:38 -07:00
Konrad `ktoso` Malawski
7c0e1f599a [Concurrency] Fix embedded, cannot refer to runtime/env vars from Actor.cpp 2024-05-28 18:19:55 +09:00
Konrad `ktoso` Malawski
e9b25d1091 [Concurrency] Move innermost record assertion to handle more gracefully 2024-05-28 16:58:38 +09:00
Konrad `ktoso` Malawski
153806b71a [Concurrency] Reshape initial values of executor checking so tests pass on Linux 2024-05-27 17:02:26 +09:00
Konrad `ktoso` Malawski
d36f99540c [Concurrency] Always assume that if expecting main actor and are on main thread that this is equal 2024-05-27 17:02:26 +09:00
Konrad `ktoso` Malawski
7790609fc8 [Concurrency] Futher prevent crashes in legacy mode of isCurrentExecutor 2024-05-27 17:02:26 +09:00
Konrad `ktoso` Malawski
481c928d67 [Concurrency] Fix missing return in legacy isSameExecutor mode detection
resolves rdar://128425368
resolves rdar://127400013
2024-05-27 17:02:25 +09:00
Holly Borla
1011e4ddb0 [Concurrency] Only deprecate AnyActor, and update more tests.
Obsoleting `AnyActor` in Swift 6 blocks the Concurrency library itself
from migrating to Swift 6, because `Actor` and `DistributedActor` have to
preserve their refinement of `AnyActor` to avoid breaking code currently
using the marker protocol. There's no way to move protocol refinement into
an extension so that the use-site declaration can be obsoleted, so we're
stuck with just the deprecation of `AnyActor`.
2024-05-24 12:58:02 -07:00
Holly Borla
7af38860ed [Concurrency] Deprecate and obsolete AnyActor.
This marker protocol isn't useful for abstracting over actors and distributed
actors because it doesn't have any runtime requirements, so there's no way
to switch to the given actor. Instead, you should use `isolated (any Actor)?`
parameters, and the compiler will compute a local actor value from a
distributed actor using `DistributedActor.asLocalActor`.
2024-05-24 08:57:17 -07:00
Mike Ash
634295c85e Merge pull request #73796 from mikeash/fix-resume-function-for-logging
[Concurrency] Refine getResumeFunctionForLogging to avoid reading invalid future contexts.
2024-05-22 16:57:37 -04:00
Andrew Trick
2640ff613b Revert "Fix quadratic performance of the ListMerger in specific usage pattern" 2024-05-21 16:23:57 -07:00
Mike Ash
0f226b6667 [Concurrency] Refine getResumeFunctionForLogging to avoid reading invalid future contexts.
When using a future adapter, the resume context may not be valid after the task starts running. Only peer through the adapter when we're starting to run.

rdar://126298035
2024-05-21 16:22:40 -04:00
John McCall
e1a82f622e Merge pull request #70910 from nickolas-pohilets/mpokhylets/fix-list-merger-performance
Fix quadratic performance of the `ListMerger` in specific usage pattern
2024-05-20 17:26:34 -04:00
Mike Ash
dd24d8e71f [Runtime] Don't emit signposts until the system is ready.
Emitting a signpost for the first time can trigger lazy setup of the logging system, and doing this in the wrong context can cause deadlocks. Check to see if the logging system is already set up, and only emit signposts if it has been to avoid triggering this.

As it's hard to determine if the "is it set up?" function is available in the SDK we're building against, only do this in OS builds, as it's not particularly useful in local builds.

rdar://124620772
2024-05-15 11:02:23 -04:00
Kuba Mracek
fba653708e [embedded] Explicitly install the embedded concurrency .a libraries with +x permissions 2024-05-13 10:27:26 -07:00
Mykola Pokhylets
9ba09ff63d Process incoming queue when obtaining drainer lock 2024-05-10 11:05:22 +02:00
Mykola Pokhylets
40c38f9803 Using multiple insertion points to ensure all jobs are always inserted in O(1)
Fully separated unprocessed jobs and processed jobs
Reverse jobs after updating status to minimise contention
2024-05-10 11:05:22 +02:00
Mykola Pokhylets
21a70e10c7 Fixed quadratic performance of ListMerger when each executed job creates 2+ new jobs of the same priority
See https://forums.swift.org/t/quadratic-performance-of-the-listmerger-in-specific-use-case/69393
2024-05-10 11:05:22 +02:00
Konrad `ktoso` Malawski
b2bd17635f [Concurrency] Fix too eager early return in checkIsolation mode detecting (#73495) 2024-05-09 03:12:37 -07:00
Stephen Canon
da9922d8bb Avoid using generic static members on Duration across module boundaries (#73419)
* Avoid using generic static members on Duration across module boundaries

Because the clocks are implemented in Concurrency, but Duration is in the Swift module, these don't get specialized. Add a fully-concrete internal init in Concurrency to avoid the problem.

* Call self.init(_high:low:) explicitly.

* Add availability annotation.
2024-05-04 10:40:10 -04:00
Doug Gregor
406346b4ba Merge pull request #73425 from DougGregor/task-group-next-public 2024-05-04 00:09:28 -07:00
Doug Gregor
b8d6c7f9d2 Disfavor the older next() APIs on TaskGroup 2024-05-03 12:21:35 -07:00
Doug Gregor
f85eed4858 Bring back TaskGroup.next() and ThrowingTaskGroup.next() as public API
With the introduction of `next(isolation:)` into the task group types,
we removed the public APIs for the no-argument `next()` versions,
leaving them only as `@usableFromInline internal` entrypoints for the
ABI. Because the `next(isolation:)` versions have a default argument,
this was sufficient for providing source compatibility for calls, but
not for protocol conformances.

Bring these APIs back publicly. Fixes rdar://127499568.
2024-05-03 12:09:55 -07:00
Konrad `ktoso` Malawski
dc5e354d69 [Concurrency] Reimplement @TaskLocal as a macro (#73078) 2024-05-01 20:57:20 -07:00
Holly Borla
2c2090201e [Concurrency] Preserve the mangling of AsyncStream.init(unfolding:onCancel:). 2024-04-30 09:25:23 -07:00
Alex Lorenz
7a5a0aad22 [android] misc stdlib build fixes 2024-04-29 15:54:05 -07:00
Holly Borla
38cc9511ee [Concurrency] Stage in new Async{Throwing}Stream.init(unfolding:) errors
as warnings.

Marking the closure parameter to these inits as `@Sendable` changed the
inferred isolation of closure arguments in actor-isolated contexts, which
caused new effects checker errors when accessing isolated properties and
methods without `await`. Mark these `init`s as `@preconcurrency`, and fix
the effects checker to downgrade those errors to warnings when the context
of the call is `@preconcurrency`.
2024-04-26 18:09:37 -07:00
Allan Shortlidge
a7914bba3a Concurrency: Fix a condfail in default AsyncIteratorProtocol.next().
Older compilers that do not enable `OptionalIsolatedParameters` by default must
be able to build the `_Concurrency` module.

Resolves rdar://126215750
2024-04-10 10:43:58 -07:00
Konrad `ktoso` Malawski
fb4ffb43db [Concurrency] Add missing runSynchronously to ExecutorJob (#72899) 2024-04-08 13:41:08 +09:00
Kuba (Brecka) Mracek
1371a8ca66 Merge pull request #72769 from kubamracek/embedded-concurrency-none
[embedded] Default Embedded Concurrency to SWIFT_THREADING_PACKAGE=none
2024-04-05 06:53:34 -07:00
Konrad `ktoso` Malawski
dfcf1054dd [Concurrency] Remove _unsafeInheritExecutor from public APIs, use #isolation (#72578) 2024-04-05 03:57:54 -07:00
Konrad `ktoso` Malawski
3295ddd200 [Concurrency] waitForAll and next of TaskGroups must inherit isolation (#72794) 2024-04-04 23:49:05 -07:00
Kuba Mracek
dcb60ab2d6 [embedded] Build even -macos Embedded Concurrency as THREADING=none, update dependency list 2024-04-04 15:37:55 -07:00
Kuba Mracek
a79e4347ab [embedded] Default Embedded Concurrency to single-threaded 2024-04-04 15:07:47 -07:00
Kuba (Brecka) Mracek
a263bca690 Merge pull request #72772 from kubamracek/embedded-concurrency-deps
[embedded] Add a test checking the dependencies of Embedded Concurrency runtime
2024-04-04 11:04:04 -07:00
Michael Gottesman
cf93476d0b [region-isolation] Require T in assumeIsolated<T> to be Sendable.
I had to change the APIs to always be always emit into client instead of back
deployable since silgen_name seems to interfere with @backDeployment. So I
switched the implementation so that it instead uses an always emit into client
thunk with the in source function name and a usableFromInline function that has
the silgen_name. This ensures that we still appropriately export the same symbol
as we did before, so it is ABI stable.

This was approved as part of se-0414.

rdar://122030520
2024-04-02 13:49:13 -07:00
Kuba Mracek
280123cb10 [embedded] Add a test checking the dependencies of Embedded Concurrency runtime 2024-04-02 10:33:33 -07:00
Yuta Saito
132ba8950b [Concurrency] Fix signature mismatch of _task_serialExecutor_checkIsolated
`_task_serialExecutor_checkIsolated` is defined as returning nothing in
`Executor.swift`, but it was used as returning a boolean in C++ side.
2024-03-31 04:48:50 +00:00
Doug Gregor
fb584f8934 Merge branch 'main' into async-sequence-fixes 2024-03-28 16:01:54 -07:00
Konrad `ktoso` Malawski
86f5441294 [SerialExecutor] SerialExecutor.checkIsolated() to check its own tracking for isolation checks (#71172) 2024-03-29 07:06:34 +09:00