-
Notifications
You must be signed in to change notification settings - Fork 530
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
WIP, doesn't even compile #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. |
Update: I've got |
@djspiewak Yeah, I don't know anything about macos; I can't even help testing it (I have no access to such a system). Anyway, I've merged your branch into this PR, so that your progress is visible here too. |
I think this PR will become the PR, more than likely |
Oh, if you want to just focus on Linux + epoll, that works perfectly. There's also more stuff to go through and pull out of jvm-specific areas and into jvm-native areas (e.g. the |
Okay, I'll try to look at one of those when I'll have some time. (Btw, I think you can push directly to this PR; at least I've checked that github checkbox.) |
Alrighty, I'm going to deprecate my fork's branch then and we can centralize on yours. |
Oh btw as a planning process note… Once we can get something which is mergeable, we should do that, close out this PR, and use normal PR process from that point forward |
Btw I can't actually push to your branch. Pushing to mine for now. |
Status report: I think I've got all (but one) of the tests working and all the functionality is shifted over aside from I took the time to factor out This still doesn't compile on Scala 3 because of the One thing that has come out as part of this is our conditional source matrix is getting pretty hairy. It might be worth taking a pass over things and updating our encodings to be what we want them to be (e.g. we have Anyway, apart from the FD weirdness, I think kqueue is pretty much ready to go. It could be optimized more but I'm not worried about performance yet. We're very close on this branch as a whole, tbh. Edit: I've confirmed that Linux and macOS are now basically in the same state, which is reassuring. I actually wonder if something might be odd about that particular test rather than the underlying polling system or WSTP? |
Huh, that's strange. I double checked, and the "allow edits by maintainers" is selected. I don't know what's going on. Anyway, I'm sure we'll be able to solve it with some combination of merge and push... |
This is not my observation.
|
Do segfaults manifest as fatal errors in sbt? If so then that's exactly what I'm experiencing, not a failing test. |
Oh I see what you mean. Hmm. I must have just gotten a segfault in both and assumed they were the same issue. Unfortunate. |
I think I've fixed the segfault in |
Okay, so it seems that in SN 0.4 |
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.)