-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[embedded] Default Embedded Concurrency to SWIFT_THREADING_PACKAGE=none #72769
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
[embedded] Default Embedded Concurrency to SWIFT_THREADING_PACKAGE=none #72769
Conversation
Does this imply import _Concurrency would work? |
|
@swift-ci please test |
interesting, I do really want to explore the space of no-allocation _Concurrency support looks like but thats unrelated to this change |
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.
lgtm, but I also dont understand cmake
@swift-ci please test macOS platform |
@@ -199,6 +199,8 @@ if(SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB AND SWIFT_SHOULD_BUILD_EMBEDDED_CONCURRENC | |||
set(SWIFT_CONCURRENCY_USES_DISPATCH FALSE) | |||
set(SWIFT_STDLIB_SINGLE_THREADED_CONCURRENCY TRUE) |
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.
Shouldn't this change? We should want to eventually get to being able to specify SWIFT_CONCURRENCY_GLOBAL_EXECUTOR_default = hooked
so that SWIFT_CONCURRENCY_GLOBAL_EXECUTOR
is set to hooked.
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.
Let's do it as a follow-up. If I just naively remove this line, I get...
Undefined symbols for architecture arm64:
"_swift_reportError", referenced from:
_swift_task_enqueueGlobal in libswift_Concurrency.a[7](GlobalExecutor.cpp.o)
swift_task_enqueueGlobalImpl(swift::Job*) in libswift_Concurrency.a[7](GlobalExecutor.cpp.o)
swift_task_asyncMainDrainQueueImpl() in libswift_Concurrency.a[11](Task.cpp.o)
ld: symbol(s) not found for architecture arm64
...because the hooked version (SWIFT_CONCURRENCY_GLOBAL_EXECUTOR_default = hooked
) of Concurrency still brings in the stub implementations from NonDispatchGlobalExecutor.inc, and we should instead really just have these symbols undefined in the runtime, and expect the user to provide them and link them.
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.
and we should instead really just have these symbols undefined in the runtime, and expect the user to provide them and link them.
Don't we just want to funnel this to swift_fatal_error which is already hooked?
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.
That seems like the wrong solution -- it would certainly work, but we are going to need to keep cutting down dependencies and code in the Embedded Swift Concurrency runtime, and IIUC, in hooked mode, we expect the user/platform to provide swift_task_enqueueGlobal
, and therefore the two symbols from the listing above (_swift_task_enqueueGlobal
, swift_task_enqueueGlobalImpl
) should really just not be part of the hooked build of Concurrency. Doing that sounds like a double win (besides resolving this undefined symbol problem): (1) less code = better codesize, (2) turns a runtime failure into a link time error.
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 didn't realize we made progress towards SWIFT_THREADING_PACKAGE that's good. I suspect we'd make use of that if we want to do a pure pthreads default executor etc.
@swift-ci please test macOS platform |
32f5f2d
to
dcb60ab
Compare
@swift-ci please test |
The Concurrency runtime (including Embedded Concurrency) can use different underlaying threading API via the SWIFT_THREADING_PACKAGE setting. The different options (C11 threads, PThreads, Darwin, etc.) have a large effect on what dependencies are expected to be provided by the platform. Given that Embedded Swift needs to support a variety of environments, including ones that do not have any threading APIs, the choice of the threading API should probably be a user-configurable option. Until we flesh that out, let's in the meantime default to building Embedded Concurrency as SWIFT_THREADING_PACKAGE=none -- which does not require any threading API (and e.g. locks are simply no-ops) and assumes we have a single-threaded environment.