From: Grigory Petrov Date: 2012-02-28T05:10:46+09:00 Subject: [ruby-core:42983] Re: 50$ for answering my stackoverflow question about Ruby and GIL I'm not so sure about that. I assembled the following test code. It's very straightforward and simple and will calculate an average splice time ( time scheduler will assign to a thread that is not giving it up via Thread.pass): require 'thread' require 'time' time = 10 items = [] threads = [] threads << Thread.new { loop { items << 1 } } threads << Thread.new { loop { items << 2 } } sleep time threads.each( &:exit ).each( &:join ) changes = 0 for i in 1 ... items.count do changes += 1 if items[ i ] != items[ i - 1 ] end printf( "Switch time is %.3f seconds\n", time.to_f / (changes + 1) ) The results are astonishing: Ubuntu: 0.010 second, ok OSX 10.7: 0.200 second, wtf? Windows XP: 0.350 second!!! WTF. Switching threads 3-4 times per second on most popular OS'es is VERY weird. Python slice is constant, around 10ms. And default thread scheduling on all OS'es is around 10ms too. This still don't explain terrible GUI hangs on Windows, but is very weird by itself. Best, Grigory. On Mon, Feb 27, 2012 at 11:17 PM, Eric Hodel wrote: > On Feb 27, 2012, at 9:54 AM, Grigory Petrov wrote: >> This hack works O_O. But why? What's the problem with this constants? >> From code it seems to me that Ruby thread slice is 250 milliseconds. >> Is it correct? If so, why so ridiculously big value - normal slice >> size for Windows/OSX/nix is around 10-20 milliseconds. > > The "us" unit in programs is microseconds, not milliseconds (I imagine � would be used to reduce confusion were it an ASCII character), so 0.25 milliseconds