At Fri, 7 Sep 2007 15:34:49 -0700, "Kirk Haines" <[EMAIL PROTECTED]> wrote: > Maybe, but it's irrelevant. The MySQL/Pg/whatever drivers aren't > written to be aware of Ruby internals.
It is my estimation that any application is going to have a lot of places where a ruby thread context switch is possible. > Ezra? His response simplified it. Of course there are situations > where green threads improve performance. They can be quantified very > simply, as I already have. When there are external latencies that are > not blocking the entire process, green threads can capture those > latencies and turn them into additional work. A sleep() call is such > a latency. Any pure ruby code that stays in rubyland and doesn't go > into an external extension is such a latency. A DB query that spends > most of its time inside of some C library that is external to Ruby is > not such a latency. Here is what I am trying to get at. (a) It is nonsense to say that because ruby threads are not ‘real’ they will never be as fast as ‘real’ threads or multiple processes. It is dependent, as I take you to mean, on the balance of your code between code from which context switching can happen & code from which it cannot. (b) *If* you have an application that is threadsafe, you ought to *test* it with multiple threads before you discount the possibility that you will be able to get *comparable* performance out of ruby’s threading than you will from multiple processes, esp. because running multiple threads rather than multiple processes provides some benefits. It is my belief that in general with a threadsafe mongrel app you are going to find that the best system is one that combines multiple processes to take advantage of multiple cores & of preemptive multitasking and multiple threads to take advantage of lower memory consumption and the faster context switching which ruby should provide. Obviously everything depends on (a) your code, (b) your ruby implementation, (c) your os’s scheduler, and (d) the phase of the moon, which is why you ought to test to find out what works best. best, Erik Hetzner
pgpYAMQZN4NaE.pgp
Description: PGP signature
_______________________________________________ Mongrel-users mailing list [email protected] http://rubyforge.org/mailman/listinfo/mongrel-users
