Interesting discussion! :)

> On the other hand they [fibers] are in no way a suitable replacement for 
> native-
> threads. They don't allow true concurrent access on one to N number of
> cores. Any blocking operation wrapped up in a Fiber is still a
> blocking operation.

They're definitely not as good as "real" threads, though...they do
allow for an event driven architecture [single threaded],
which...strikes me as being overall more scalable.  The real
difference between evented and a thread pool might be neglible.  I
remember in benchmarks comparing evented mongrel and mongrel the only
real "win" for evented mongrel was at really high concurrency [i.e.
tons of Ruby threads], where it didn't die [and normal mongrel did].

All these are just hacks to try and get the MRI to perform well.

That being said, MRI 1.9 can really only use one core anyway so...it
makes sense to use event driven instead of a thread pool, but probably
to only save on a teeny bit of overhead.  I think someone should come
up with a thread pool patch for mongrel/rails--that might be an
excellent idea.

Note also that you CAN combine threads and evented processing--doesn't
make much sense with MRI though, since you can only use one core
anyway.  Perhaps the ideal would be using an evented model and "a few"
threads just so that one CPU hog request doesn't slow down all the
other requests, but the real increase, again, might be minimal.

With JRuby hopefully fibers aren't even necessary [as long as you
don't spawn too many threads... :P ].

In all honesty I think the thing that DataMapper could benefit from
most would be non blocking IO--if it wants to be truly "thread
friendly" then that would seem like a nice feature.  I suppose it
already is so if run under JRuby [but not currently MRI ?].  If the
fibers thing ever takes off it's something like a piece of cake to
incorporate it into a query.

def fiber_friendly_query *args
   fiber = Fiber.current
   conn.async_execute_when_the_data_comes_back { |data|
       fiber.resume data
   }
  Fiber.yield
end

And that's it.  I guess there's more but that's about all.  But that's
really an optimization for another day.

Thanks for your time.
-=R
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to