From: Robert Klemme Date: 2008-10-06T18:40:14+09:00 Subject: Re: Concurent (using threads) slower than sequential -doubt 2008/10/6 Yukihiro Matsumoto > > In message "Re: Concurent (using threads) slower than sequential -doubt" > on Mon, 6 Oct 2008 12:40:08 +0900, Carlos Ortega writes: > > |As you see, the thread based program run slower. > |I thought that by using threads it will be faster, but it didn't....Why > |is it slower? > > Threads require context switching, so that they tend to run slower, > especially green threads like Ruby 1.8 has. There is another issue which may easily have a more serious impact: since all three files reside in the same directory they are read from the same physical device (most likely a local (S)ATA disk). And since these files are large chances are that they are spread over the disk and do not fit into the operating systems buffer cache. This will lead to reasonably more head movement and less efficient disk caching than the sequential approach. Kind regards robert -- remember.guy do |as, often| as.you_can - without end