-
Notifications
You must be signed in to change notification settings - Fork 534
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
Add support for Native multithreaded execution #4201
base: series/3.x
Are you sure you want to change the base?
Conversation
So, I'm running this on Linux, and without 489fbb9 it tries to use EDIT: what I wrote above is probably completely wrong... 🤷♂️ |
This is great! Thank you for pushing this forward to the next obstacle. One of the things that occurred to me as I poked at my branch originally is SN's tooling for introspecting thread state is really really limited so far as I understand it. Maybe this is just my ignorance and LLVM has some magic we could turn on, but I strongly suspect we're going to need better introspection to run down some of these problems. What I'm thinking is we're probably going to end up building that, or at least leaning in heavily to do so, and that's probably a large part of what we'll need to do to get this off the ground. We should chat with the SN folks. |
The reason it's hanging is because we haven't implemented interruption yet for the Native I/O-polling systems. This wasn't necessary when it was single-threaded, but now it's critical :)
Compare with: cats-effect/core/jvm/src/main/scala/cats/effect/unsafe/SelectorSystem.scala Lines 97 to 100 in 9ce05f2
|
Oh, the other reason it may be hanging is indeed related to GC. On Scala Native, blocking native calls need to be annotated explicitly with the For now it's fine to just mark it |
You know, I didn't even think about this. Makes loads of sense though. Pipes time! |
@armanbilge Thanks, I've tried to do the 2 things you mentioned. In 62b8141 I turned on the |
// TODO: this is not threadsafe, we're reading `interruptFd` without synchronization: | ||
if (unistd.write(this.interruptFd, buf, 8.toCSize) == -1) { |
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.
It doesn't need to be, it will be synchronized by workerThreadPublisher
at its callsites.
cats-effect/core/jvm/src/main/scala/cats/effect/unsafe/WorkStealingThreadPool.scala
Lines 324 to 326 in 8d92651
workerThreadPublisher.get() | |
val worker = workerThreads(index) | |
system.interrupt(worker, pollers(index)) |
Interesting. So I merged your branch with
Edit: Appears to be a macOS only thing. Compiles and runs on Linux. Lovely. |
Okay got around the issue with Lorenzo's help. It's fixed in SN main, so I updated to a local snapshot (lol) on my branch and made progress. I'll dig into interruption for kqueue |
Update:
Will get back to this later. |
I pushed more. Kqueue is pretty close to working I think. |
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.
We definitely need to figure out how to start sharing code across platforms more sanely. :P
Latest from CI ... this is reminiscent of the issues we are having in Cats, where test suites just error out 😕
|
Locally is a bit more promising 🤔
|
I saw that happen when any individual test segfaults: it seems to cause a whole cascade of ghost errors. |
I no longer see segfaults locally on mac. Haven't tried Linux yet. Oh as an aside, the problems I had pushing to this remote were being caused by git-lfs. In case anyone else sees these types of issues, the solution is to use the |
89c862c
to
22271cc
Compare
I still do 😕
|
Nuts. I wonder if I just didn't run it enough. |
This is on top of @djspiewak's
wip/multithreaded-wstp
branch. I did nothing so far, except default toSleepSystem
in 489fbb9. This makes it possible to runIOSpec
on scala-native; it (sometimes) passes on my machine ;-). It's probably too early to have this as a PR, but I'm doing it anyway to avoid duplicating work, and maybe to have a discussion aboutEpollSystem
(see below). (@djspiewak feel free to close this PR if you have other plans with your branch.)