From: Charles Oliver Nutter Date: 2011-04-11T08:08:24+09:00 Subject: [ruby-core:35692] Re: caching of the ancestor chain On Fri, Apr 8, 2011 at 7:56 PM, Yukihiro Matsumoto wrote: > Hi, > > In message "Re: [ruby-core:35667] Re: caching of the ancestor chain" > �� ��on Sat, 9 Apr 2011 09:40:59 +0900, Xavier Noria writes: > > |So I wonder whether this is a design sacrifice for optimization purposes. > > Yes, kind of. ��If you can find a way to implement "proper" mixin > relationship as efficient as it currently is, I'd love to take it. What's actually slow about this? JRuby caches nothing but runs the following benchmark 3x faster than 1.9.2p160 (and it's not Ruby execution performance): cls = Class.new 20.times { cls = Class.new(cls) } 5.times { puts Benchmark.measure { 1000000.times { cls.ancestors } } } ~/projects/jruby ��� jruby -rbenchmark -e "cls = Class.new; 20.times { cls = Class.new(cls) }; 5.times { puts Benchmark.measure { 1000000.times { cls.ancestors } } }" 1.002000 0.000000 1.002000 ( 0.956000) 0.510000 0.000000 0.510000 ( 0.511000) 0.474000 0.000000 0.474000 ( 0.474000) 0.493000 0.000000 0.493000 ( 0.493000) 0.466000 0.000000 0.466000 ( 0.466000) ~/projects/jruby ��� ruby1.9 -rbenchmark -e "cls = Class.new; 20.times { cls = Class.new(cls) }; 5.times { puts Benchmark.measure { 1000000.times { cls.ancestors } } }" 1.350000 0.060000 1.410000 ( 1.450674) 1.370000 0.070000 1.440000 ( 1.511301) 1.350000 0.050000 1.400000 ( 1.463408) 1.350000 0.060000 1.410000 ( 1.466519) 1.360000 0.070000 1.430000 ( 1.478440) Am I misunderstanding the original question? - Charlie