From: Eric Hodel Date: 2010-12-15T04:27:11+09:00 Subject: Re: Ruby 1.9.2 : Io performance when application use multithread On Dec 14, 2010, at 11:07, Eric Hodel wrote: > On Dec 14, 2010, at 05:34, Regis d'Aubarede wrote: >> The file attachment is an simple script for measure performance >> between client TCP and server, in Mbyte/s. >> >> With Ruby 1.9.2, when the server run in multi thread >> ( Thread.new(serv.accept()) {...} ) the script give >> a very poor transfer rate ( 3Mbyte on connection on localhost ). >> >> When none-multi thread, performance is good : >> same as jruby and MRI ( 470 Mbyte/s ) >> (ironRuby give a stange 110 Mbyte/s). >> >> Usage : >>> ruby gbits.rb server 4040 # server (monothread) >>> ruby gbits.rb server 4040 t # server (multihread) >> >>> ruby gbits.rb client 127.0.0.1 4040 10 # 10=> 10 MB data length >> >> OS: Windows 7 >> Proc: core i7, 1 Gbps ethernet >> Ruby: 1.9.2dev (2010-07-02) [i386-mingw32] >> jruby: 1.5.0 >> ir: 1.1.0.0 on .NET 4.0.30319.1 >> ruby: 1.8.6 >> >> >> Tested on Linux >> Ubuntu 10.4 (same machine with Virtalbox) >> ruby 1.9.1p378 (2010-01-10 revision 26273) [i486-linux] >> >> server threaded : 844 MB/s >> server non-threaded: 989 MB/s >> same delta with jruby > > On OS X 10.6 I don't see a performance drop for threaded vs non threaded. I ran your script with an argument of 1000 instead of 10 as the results for 10 were too variable. > > ruby 1.9.3dev (2010-12-04 trunk 30078) [x86_64-darwin10.5.0] runs ~ 420MB/s both By increasing the sending and receiving buffer sizes to 64KB and using syswrite/sysread I was able to increase performance to 565MB/s with 1.9.3dev. I suspect you'll see a similar increase on other versions as well. You can find my modified version here: http://paste.segment7.net/jc.html For the windows slowdown, perhaps better buffer sizes will help. It's possible that in threaded mode your odd-sized buffers are causing some kind of starvation. If this doesn't help your speed issue try reporting this to the ruby-core mailing list.