Drop Crystal::FiberChannel#14949
Conversation
ysbaddaden
left a comment
There was a problem hiding this comment.
Fiber.yield enqueues a 0 second timer, so the next event loop wait won't block. Don't we enter a busy loop when there's nothing to do but wait on the event loop?
|
I almost managed to replace it with I believe the use of EDIT: Nevermind, it looks like |
|
Handling the parked/sleeping state is very tricky, especially in MT. The IO pipe enables a double trick: it allows the run loop to enter the parked/sleeping state, while making sure that there's always something in the event loop. For example libevent won't block if there are no registered event/timer (nothing to wait for) so with this change the thread will enter a busy-loop again when it happens —and won't our IOCP evloop do the same? Note: the IO pipe would also work for Windows/IOCP if reading from the reader was nonblocking. Maybe we can find an alternative to FiberChannel on Windows, and keep it otherwise? |
|
In practice, the fiber stack pool reaper should ensure every thread's scheduler always has something to await since #14100, something not true when we started using |
|
Actually the point about IOCP is already somewhat true even without |
|
It looks like overlapped I/O operations don't always use events either; if they have no timeouts, then |
|
I'm not sure what's the status of this. Do we want to merge this change or leave it as is due to the upcoming changes with execution contexts? |
|
Today: removing While the assumption is true, it's a bit fragile 🫤 If we drop the stack-pool-collector fiber, then the As stated by @HertzDevil: IOCP is broken because it only keeps track of timers and won't try to check for completion otherwise. It's only working thanks to the Near future: the Proposal: Quinton's idea of the IOCP evloop assuming a +infinite timeout is a good idea, it would avoid having to keep track of operations. The Polling evloops already do that when blocking is true, and we could instruct libevent to do just the same ( |
|
As for this PR I'm not sure. I'd keep BTW: |
|
Alternative: tell That could become a requirement of evloop implementations. The polling eventloop already blocks forever, and so does the refactored IOCP evloop (#15238) We wouldn't need |
Fixes #14222. This doesn't affect
IO.pipe's behavior on Windows.