From: Eric Wong Date: 2014-11-15T22:39:38+00:00 Subject: [ruby-core:66305] Re: [ruby-trunk - Feature #10423] [PATCH] opt_str_lit*: avoid literal string allocations 2 patch series: 1. http://80x24.org/spew/m/opt_str_lit-v8-prepare@0.txt (allow disabling existing optimizations) 2. http://80x24.org/spew/m/opt_str_lit-v8@1.txt (enable new optimizations) Changes since -v7: * opt_str_lit*: avoid string literal allocations * rb_undo_opt_str_lit is now a VM option * template/opt_method.h.tmpl: explicitly cast to signed * remove Time#strftime and opt_str_lit_data insns (too specialized) * keep opt_aref_with and opt_aset_with (for speed) Rebased on top of r48453 I decided to keep opt_{aref,aset}_with despite being less elegant to avoid performance regressions from trunk (I removed opt_str_freeze, however). I also reinstated bytecode patching to disable optimization as a VM option since we do not have CoW-friendly bytecode or JIT, yet. Also pushed to my git repo: git://80x24.org/ruby.git opt_str_lit-v8 Performance difference is still minor, "make gcbench-rdoc" results: before: user system total real 60.630000 0.720000 61.350000 ( 61.424623) GC total time (sec): 4.268761704000086 VmHWM: 290040 kB Summary of rdoc on 2.2.0dev 61.42462271545082 4.268761704000086 145 (real time in sec, GC time in sec, GC count) after: user system total real 58.830000 0.700000 59.530000 ( 59.601977) GC total time (sec): 4.048253329998705 VmHWM: 289536 kB Summary of rdoc on 2.2.0dev 59.60197714343667 4.048253329998705 131 (real time in sec, GC time in sec, GC count) Eventually I'd like this to work more generically (for pure-Ruby classes) and perform lazy dup at method dispatch, but that is a lot of work.