Issue #9159 has been updated by tmm1 (Aman Gupta).


One example of strings de-duplicated by this patch are iseq labels. Before:

  irb(main):001:0> mm = "method_missing"
  irb(main):002:0> GC.start; ObjectSpace.each_object(String).select{ |o| o == mm }.size
  => 77

After:

  irb(main):002:0> GC.start; ObjectSpace.each_object(String).select{ |o| o == mm }.size
  => 3

----------------------------------------
Bug #9159: [patch] use rb_fstring for internal strings
https://bugs.ruby-lang.org/issues/9159#change-43168

Author: tmm1 (Aman Gupta)
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: current: 2.1.0
ruby -v: ruby 2.1.0dev (2013-11-26 trunk 43852)
Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN


I added rb_fstring wrappers around internal strings generated by iseqs, regexps and eval:

  https://github.com/tmm1/ruby/commit/9587fae171835ccf013661ba837f097754f170ef

In our rails app, this reduces the number of long-lived strings on the heap by 30%.

      $ ruby -rconfig/environment -e' GC.start; p ObjectSpace.count_objects[:T_STRING] '
      246100

      $ ruby -rconfig/environment -e' GC.start; p ObjectSpace.count_objects[:T_STRING] '
      173956

If this patch is acceptable, I can commit it. make test and test-all pass.


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