Feature #20053
closedM:N Threads, now w/ macOS support (kqueue)
Description
I have a PR here that adds support for macOS to M:N threads using kqueue
: https://github.com/ruby/ruby/pull/9178
It adds in kqueue
/kevent
calls when present in the OS. Technically this would open up support for FreeBSD as well, but I don't have a way of testing that so i'm not sure how well it does or doesn't work there.
I wanted to get support going for macOS so more devs can try out M:N threads and test it. I do think there should be a larger discussion around the potential relationship between this and some of the awesome fiber scheduler work over the last few years (and the potential of utilizing anything from io-event?). But that can be a topic for another day - let's get macOS support in the meantime!
Disclaimer: C isn't my day-to-day language, so I could definitely use feedback there. I'm also more of a kernel event queue (kqueue, epoll, io_uring) enthusiast, but kqueue
isn't something I have specific experience writing with - just lots of reading code and small toy code up until this point. So someone like @ioquatix (Samuel Williams) would probably be a good person to get eyes on it.
Updated by byroot (Jean Boussier) about 1 year ago
- Assignee set to ko1 (Koichi Sasada)
Updated by jpcamara (JP Camara) about 1 year ago
@ko1 (Koichi Sasada) you’ll see a huge amount of discussion on the PR between me and @ioquatix (Samuel Williams) - you can ignore all of that and just look at the PR code. I will open up a separate issue to discuss that separately from this kqueue work.
I’ve made some changes since I first opened the PR - some small refactors for clarity, and all the tests pass now. It’s stable now and I won’t make any other changes (unless you request some!).
Updated by jpcamara (JP Camara) about 1 year ago
@ko1 (Koichi Sasada) My updates are in based on your feedback. At this point is it too close to the Ruby 3.3 release to potentially get Mac support in?
I also responded about the scenario in #readpartial
where native threads end up getting created in MN threads. I think I may have a solution - but since it was present before this PR, i'll open a separate PR for the fix.
Updated by hsbt (Hiroshi SHIBATA) about 1 year ago
- Status changed from Open to Assigned
Updated by hsbt (Hiroshi SHIBATA) about 1 year ago
- Status changed from Assigned to Closed
https://github.com/ruby/ruby/pull/9178 has been merged.