Skip to content

Conversation

al45tair
Copy link
Contributor

@al45tair al45tair commented Jun 24, 2025

We're changing our approach to Clock support in executors such that a clock that isn't recognised by an executor will result in a call to an enqueue method on Clock itself; this will allow clocks to have control over exactly how they schedule jobs in cases where the executor doesn't already know what to do.

Also includes a small bug fix for CooperativeExecutor and some updated comments.

rdar://154191435

@al45tair al45tair requested review from a team and ktoso as code owners June 24, 2025 14:07
@al45tair al45tair requested a review from rjmccall June 24, 2025 14:09
@al45tair
Copy link
Contributor Author

@swift-ci Please smoke test

@al45tair al45tair force-pushed the concurrency-updates branch from 2a19c34 to 8c00ea0 Compare June 26, 2025 10:32
@al45tair
Copy link
Contributor Author

@swift-ci Please smoke test

Copy link
Contributor

@ktoso ktoso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, sorry about the docs nitpicks! I don't actually have a great way to preview those in tree I guess 🤔

@al45tair
Copy link
Contributor Author

lgtm, sorry about the docs nitpicks! I don't actually have a great way to preview those in tree I guess 🤔

No worries. I think you're right about the doc comments; I'll go and update them all.

@al45tair al45tair requested a review from jckarter as a code owner July 2, 2025 13:25
@al45tair al45tair force-pushed the concurrency-updates branch from 38ead6d to 262f07a Compare July 2, 2025 14:13
@al45tair
Copy link
Contributor Author

al45tair commented Jul 2, 2025

(Haven't updated doc comments yet; that's the next job…)

@al45tair
Copy link
Contributor Author

@swift-ci Please test

1 similar comment
@al45tair
Copy link
Contributor Author

@swift-ci Please test

@al45tair al45tair force-pushed the concurrency-updates branch from ad9b463 to c0adefc Compare July 15, 2025 09:59
@al45tair
Copy link
Contributor Author

@swift-ci Please test

2 similar comments
@al45tair
Copy link
Contributor Author

@swift-ci Please test

@al45tair
Copy link
Contributor Author

@swift-ci Please test

@al45tair
Copy link
Contributor Author

@swift-ci Please test Windows platform

@al45tair
Copy link
Contributor Author

Linux looks like some WASI related problem, possibly to do with the cooperative executor?

@al45tair
Copy link
Contributor Author

al45tair commented Aug 4, 2025

@swift-ci Please test

@al45tair
Copy link
Contributor Author

@swift-ci Please test Windows platform

1 similar comment
@al45tair
Copy link
Contributor Author

@swift-ci Please test Windows platform

@al45tair al45tair force-pushed the concurrency-updates branch from 910770b to d795762 Compare August 21, 2025 13:14
@al45tair
Copy link
Contributor Author

@swift-ci Please test

@al45tair
Copy link
Contributor Author

@swift-ci please test Windows platform

1 similar comment
@al45tair
Copy link
Contributor Author

@swift-ci please test Windows platform

@al45tair
Copy link
Contributor Author

@swift-ci Please test Windows platform

2 similar comments
@al45tair
Copy link
Contributor Author

@swift-ci Please test Windows platform

@al45tair
Copy link
Contributor Author

@swift-ci Please test Windows platform

@al45tair
Copy link
Contributor Author

@swift-ci please test Windows platform

@al45tair al45tair force-pushed the concurrency-updates branch from d795762 to 972af40 Compare August 25, 2025 10:27
@al45tair
Copy link
Contributor Author

(Rebased)

@al45tair
Copy link
Contributor Author

@swift-ci Please test

We no longer attempt to convert timestamps from the passed-in `Clock`
in order to allow any clock to work with any executor.  Instead,
executors that do not recognise a clock should call the `enqueue`
function on that `Clock`, which lets the `Clock` itself decide how
to proceed.

Additionally, rename `SchedulableExecutor` to `SchedulingExecutor`.
…cks.

The built-in clocks should have implementations of `run` and `enqueue`,
to allow derived clocks to call those implementations.
I don't think we actually need this.  If you have a non-canonical
(i.e. derived) clock, you can just implement `enqueue` and/or `run`
and call those methods on the clock you're wrapping.
If a job enqueues another job on the executor, we might never leave
the inner `while` loop in the `run()` method.  Fix this by taking
the contents of the run queue and only running those jobs in the
queue at the time we enter the inner loop.
Add some documentation comments to the Dispatch and CF executors,
and update the comments for the allocation and private data APIs.
Rather than just looking at top level in the module, start by searching
the type marked as `@main`.  This means that a library that provides a
protocol or superclass that the `@main` type can conform to can specify
an executor in a reasonable manner.
Also add `final` to the `CooperativeExecutor` declaration.
We've removed this code, so the test was failing.
…run.

We were terminating after the first set of jobs; if one of them scheduled
another job, and there were no timers running, we would terminate,
which was wrong.
There was still some canonicalization in one of the tests, plus we needed
to update the ABI tests.
Some mentions of `ExecutorJob` were not guarded by the required
`SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY` condition.
@al45tair al45tair force-pushed the concurrency-updates branch from fba50db to d6224d1 Compare August 26, 2025 08:38
@al45tair
Copy link
Contributor Author

@swift-ci Please test

@al45tair al45tair merged commit 687e09d into swiftlang:main Aug 27, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants