4 ms·
Would Ruby benefit if we put epoll(7) or io_uring(7) on IO boundaries and then do something like Go or BEAM where we preempt at a certain number of function cal
by jhyaaasdfw 2y ago
Would Ruby benefit if we put epoll(7) or io_uring(7) on IO boundaries and then do something like Go or BEAM where we preempt at a certain number of function calls or time? One challenge I see with this approach is calling into C libraries although I don't know how common that is in Ruby ecosystem.
- davexunit 2y agoIt's pretty common to call into C libraries in Ruby. Many widely used Ruby gems have what are called "native extensions". The approach that I know of to deal with this problem is that captured continuations with C stack frames are marked as non-resumable. Trying to resume such a continuation throws an exception. As the programmer, you'd write your async code in a way that avoids calls to C that call back into Ruby to prevent capturing non-resumable continuations.
- xerxes901 2y agoThis is in fact exactly what Ruby’s Fibers and the async fiber-scheduler gem do