On Wed, Sep 15, 2010 at 7:01 AM, David Masover <ninja / slaphack.com> wrote:
> On Tuesday, September 14, 2010 11:07:10 pm Chuck Remes wrote:
>> On Sep 14, 2010, at 10:59 PM, Terry Michaels wrote:
>> > I read a Ruby e-book recently that indicated that although Ruby has
>> > Multi-threading capabilities, it is a fake multi-threading. I.e., the
>> > interpreter simply switches between the executing threads, rather than
>> > running them concurrently.
>> >
>> > Then recently I came across an online Ruby tutorial that specifically
>> > said that Ruby threads could be executed in parallel on a multi-core
>> > machine. So I'm a little confused.
>> >
>> > Does Ruby have real multi-threading, or is it just context switching?
>> > This is a rather important issue for me.
>>
>> Just about any book on this topic will have outdated information. Here's
>> the breakdown.
>
> Nice summary, mostly accurate. I'd just like to add that, interestingly...
>
> JRuby doesn't have great process management. It has OK process management, but
> it seems limited by the JVM. This may be better now, and I may be entirely
> wrong, but I wouldn't trust fork here.
>
> With MRI, on the other hand, fork has always worked. The only sticky part is
> that no mainstream versions of MRI play nice with COW, which means the entire
> process memory _will_ be copied as soon as GC runs.
>
> The usual answer seems to be: Use JRuby if you really want threads, but most
> Ruby people care more about scaling to multiple machines more than multicore
> on the same machine, at which point it becomes really easy to just spin up a
> bunch of MRIs.

... using DRb for example which makes IPC a breeze.  Absolutely agree.

Btw, with regard do concurrency: for applications which are IO bound
even MRI's threading model is often sufficient because IO operations
do not block the process but rather give CPU to other threads.  The
best is of course to test and benchmark to see whether performance is
sufficient - something true for all kinds of applications and
runtimes.

Kind regards

robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/