Thanks it was a fun to dive back into the multiplexing loop logic and finally refresh that code with socket action from libcurl and new ruby APIs...
1. the C parser in libcurl is much faster then ruby's and libcurls support for HTTP/2 and multiplexing - even back in 2010 while at LivingSocial we used curb to improve site throughput (it's improved a lot these days) with the multi interface at my current company CTM we can push out millions of webhook requests with very little CPU burn.
2. Fiber support is needed because like a normal C extension would call a function to open a socket write some bytes, wait, write some more and then wait, and read some, wait and read some more again. All of this while basically the CPU is idle and we're just waiting there blocking a whole ruby thread or even worse process (typical ruby process running rails could be pretty big too so that's a lot of memory consumed just waiting around doing basically nothing). Ruby threading model really helped this and curb was one of the few libraries or only one i know of that played nice with the ruby global interperter lock so multi-thread web apps could do stuff on other threads while one thread was blocked waiting on IO. With this new curb update now a single thread can do multiple http requests with overlapping IO meaning while one fiber is waiting another fiber can do some busy work like queue up more http requests or read something from a db.
3. The key is we're rb_wait_for_single_fd so any reactor (if i'm understanding what a "reactor" really is correctly) can run and do busy work while we're waiting on a file descriptor. It should* work correctly now, if you run into issues i'd love to know about it and help get them fixed.
What I'm hoping for now for ruby is either puma implements a Fiber pool rails db adaptors fully add fiber support then we should as a ruby community have a really nice story around multiplexing I/O to be more competitive with node.js / golang for web socket and other I/O heavy workloads. By competitive here i mean we can use less memory since we'll be able to keep our CPU's busy while we wait for the network or even disk (maybe).