From: Francis Cianfrocca Date: 2007-01-30T00:56:40+09:00 Subject: Re: Benefits of Multi-Threading? ------=_Part_54744_32378068.1170086198853 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 1/28/07, khaines@enigo.com wrote: > > On Mon, 29 Jan 2007, Justin Collins wrote: > > > There are two main reasons for using multi-threaded applications, even > on a > > single processor: > > > > The first is performance. It's faster to switch between threads than it > is > > between processes, and it's (typically) even faster to switch between > > user-level threads like Ruby has. Also, any asynchrony in your program > (like > > That's a bit of a red herring, though. With Ruby's green threads, every > active (i.e. not sleeping) thread that is added to a single process > reduces the overall throughput of all of the threads, collectively, by a > noticable amount. While two separate processes on a single processor may > have less throughput than two threads in a single ruby process, those two > threads will have less throughput than a single thread. So, a single > thread solution will typically be more performant than multi-thread > solution under Ruby's current threading model. I'll second that and add this: Ruby works around the classic green-thread problem (blocking the whole process when a single thread blocks in a system call) by polling a medium-frequency timer interrupt. Total performance in a Ruby program with two threads isn't just lower than in single-threaded program- it's a LOT lower. ------=_Part_54744_32378068.1170086198853--