[MacRuby-devel] Fibers and Enumerators

Ernest N. Prabhakar, Ph.D. prabhaka at apple.com
Fri Aug 13 11:10:00 PDT 2010


Hi Logan,

On Aug 13, 2010, at 10:49 AM, Logan Bowers wrote:
> To your point Ernie, yes fibers can be almost perfectly emulated using threads. A good, native fiber implementation, however typically uses  significantly less memory/fiber and context switches are significantly faster vs a thread-based implementation. 

Ah, yes.  That is why GCD is actually built on queues, rather than threads.  GCD will only spin up a new thread when necessary; otherwise it'll just reuse existing idle threads, so you don't pay any startup cost.

I'd be willing to bet a nice dinner anywhere in the South Bay that you can implement Fibers on top of GCD as efficiently as they are implemented natively in Ruby 1.9.  The only difference is that the system can -also- schedule them on real kernel threads, for much better performance on multicore systems. 

-- Ernie P.


More information about the MacRuby-devel mailing list