From: Kent Sibilev Date: 2006-09-05T04:37:23+09:00 Subject: Re: The real difference between Mutex and Sync This patch will make Mutex a bit slower, but much better in terms of garbage collection: Index: lib/thread.rb =================================================================== RCS file: /src/ruby/lib/thread.rb,v retrieving revision 1.16.2.2 diff -r1.16.2.2 thread.rb 99c99 < @waiting.push Thread.current --- > @waiting.unshift Thread.current 115c115 < t = @waiting.shift --- > t = @waiting.pop On 9/4/06, Kent Sibilev wrote: > On 9/4/06, Kent Sibilev wrote: > > On 9/4/06, khaines@enigo.com wrote: > > > > > > array.c's behavior is what needs to be examined in greater detail, here. > > > Mutex, itself, is not doing anything surprising. > > > > > > > > > Kirk Haines > > > > > > > Good findings. > > > > I think the problem lies in the Array#shift (rb_ary_shift) > > implementation. Basically, it just increments the internal pointer and > > it never modifies the size of an array. This means that if you have an > > array with 1000 elements and you 'shift' it 999 times, all these > > elements are still visible to the garbage collector, until you modify > > this array by triggering rb_ary_store method, for example. > > > > I meant that rb_ary_shift never modifies the size of allocated memory. > > -- > Kent > --- > http://www.datanoise.com > > -- Kent --- http://www.datanoise.com