[MacRuby-devel] Fibers and Enumerators

Logan Bowers logan at datacurrent.com
Fri Aug 13 10:49:47 PDT 2010


I'm with Easco in that I'm patiently waiting for the day Fibers are supported (or when I have time to contribute) and am happy waiting as long as the duration is bounded. E.g. If I were waiting for fork(), it sounds like I'd be here awhile. 

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. 

Fibers are used instead of threads in applications that depend on those advantages. So while emulating the fiber interface with threads would technically increase MacRuby's conformance, the practical value would be somewhat limited. 

The use case for me is somewhat more Easco is somewhat more practical. Most servers on the Internet use a thread-per-request model, which is good for concurrent workloads up to a few hundred concurrent requests. Yes, technically you can allocate more threads on a modern system, but rarely have I seen the number go much higher for a complex workload. Many of these servers are I/O bound, so increasing the concurrency would increase throughput. I'd like to take some of my workloads to 100,000+ concurrent requests. Threads cannot help me at that scale. 

That may sound like an esoteric use case, but with websockets and Comet, it's actually pretty common. 

Sent from my iPhone

On Aug 13, 2010, at 10:15 AM, "Ernest N. Prabhakar, Ph.D." <prabhaka at apple.com> wrote:

> Hi Easco,
> 
> On Aug 13, 2010, at 8:15 AM, easco wrote:
>> Instead I was curious to know if there was "a plan" for implementing Fibers and if so, I was curious to know what operating system technology they would be built on.  It appears that the problem has not been looked at, in-depth, yet and I am satisfied with that.  Nor does it appear that there is any OS level technology that would particularly support the creation of Fibers (i.e. Mac OS X doesn't really have any built-in support for cooperatively scheduled multitasking... outside of deprecated technologies like the Carbon Thread Manager and makecontext/swapcontext).
> 
> Actually, I'm confused by that statement. My understanding is that cooperatively scheduled threads is a just a subset of the system-scheduled model.
> 
> In particular, I'm pretty sure you can emulate them on top of GCD using semaphores.  Should I explain further, or did you already consider that and discover it was unworkable?
> 
> -- Ernie P.
> 
> 
> 
> 
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


More information about the MacRuby-devel mailing list