Feature #2594: 1.8.7 Patch: Reduce time spent in gc.c is_pointer_to_heap().
http://redmine.ruby-lang.org/issues/show/2594

Author: Kurt  Stephens
Status: Open, Priority: Normal
Category: core, Target version: Ruby 1.8.7

gc.c:

Rationale:
* The size of struct heap_slots grows exponentially.
* add_heap() puts new heaps on the end of the heaps[] array.
* The newest heaps are placed toward the end.
* The newer heaps are larger, thus are more likely to contain valid pointers than smaller heaps.
* sort_heaps() reorders the heaps[] array such that early probes are more likely to match in larger heaps.

This was developed under REE 1.8.7, and ported to 1.8.7.

Patches:

MRI 1.8.7: http://github.com/kstephens/ruby/commit/263551bbf8e52aa031433e4e00936f41760b3980
REE 1.8.7: http://github.com/kstephens/rubyenterpriseedition187/commit/d69554f0b37331a597f8837abba37c302701d292

See also: http://code.google.com/p/rubyenterpriseedition/issues/detail?id=24&colspec=ID Type Status Priority Milestone Summary

Measurements: ~ 2% faster overall:

cnuapp@kurt-4:/export/bug/103302/cnu_ruby_build/rubyenterpriseedition187$ ./ruby ../test_gc_options.rb
WARMUP:
./miniruby -I./lib -I.ext/common -I./- -r./ext/purelib.rb -r ../close_fds.rb ./runruby.rb --extout=.ext  -- ./test/runner.rb --basedir=./test --runner=console:

  RUBY_GC_SORT_HEAPS=0 RUBY_GC_COPY_ON_WRITE_FRIENDLY=0 :
Command exited with non-zero status 1
189.05user 10.50system 4:25.50elapsed 75%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+10112outputs (0major+533733minor)pagefaults 0swaps

  RUBY_GC_SORT_HEAPS=1 RUBY_GC_COPY_ON_WRITE_FRIENDLY=0 :
Command exited with non-zero status 1
185.37user 10.51system 4:20.12elapsed 75%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+10120outputs (0major+529560minor)pagefaults 0swaps


----------------------------------------
http://redmine.ruby-lang.org