ruby-changes:55222
From: k0kubun <ko1@a...>
Date: Thu, 4 Apr 2019 01:06:09 +0900 (JST)
Subject: [ruby-changes:55222] k0kubun:r67429 (trunk): Introduce inline cache for invokesuper
k0kubun 2019-04-04 01:06:03 +0900 (Thu, 04 Apr 2019) New Revision: 67429 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=67429 Log: Introduce inline cache for invokesuper Looks good in micro benchmark: ``` $ benchmark-driver benchmark/vm2_super.yml -v --rbenv 'before;after' before: ruby 2.7.0dev (2019-04-03 trunk 67428) [x86_64-linux] after: ruby 2.7.0dev (2019-04-03 trunk 67428) [x86_64-linux] last_commit=Introduce inline cache for invokesuper Calculating ------------------------------------- before after vm2_super 19.265M 31.280M i/s - 6.000M times in 0.311447s 0.191813s Comparison: vm2_super after: 31280464.2 i/s before: 19264906.2 i/s - 1.62x slower ``` No significant impact to Optcarrot: ``` $ benchmark-driver benchmark.yml --rbenv='before;after' -v --output=all --repeat-count=12 before: ruby 2.7.0dev (2019-04-03 trunk 67428) [x86_64-linux] after: ruby 2.7.0dev (2019-04-03 trunk 67428) [x86_64-linux] last_commit=Introduce inline cache for invokesuper Calculating ------------------------------------- before after Optcarrot Lan_Master.nes 48.41126024010233 47.28027196127746 fps 49.49212664510990 48.75072555488074 49.51485564376117 49.20650895701073 49.58351773328487 49.24563592659139 49.64022392458479 49.26292753046641 49.92566235019630 49.44496216868009 50.18022198879376 49.45467429762771 50.33038373991723 49.52003367348857 50.43202877523305 49.69190055704068 50.61368587766504 49.79856204866324 50.77975014460643 50.27764769510704 50.89807360753746 50.35785776505005 ``` A little improvement to k0kubun/railsbench?: ``` $ rbenv shell before; RUBYOPT="-v" WARMUP=1 BENCHMARK=30000 bin/bench ruby 2.7.0dev (2019-04-03 trunk 67428) [x86_64-linux] Warmup: 1 requests Benchmark: 30000 requests Request per second: 897.1 [#/s] (mean) Percentage of the requests served within a certain time (ms) 50% 1.01 66% 1.02 75% 1.03 80% 1.04 90% 1.08 95% 1.23 98% 2.10 99% 5.52 100% 13.26 $ rbenv shell after; RUBYOPT="-v" WARMUP=1 BENCHMARK=30000 bin/bench ruby 2.7.0dev (2019-04-03 trunk 67428) [x86_64-linux] last_commit=Introduce inline cache for invokesuper Warmup: 1 requests Benchmark: 30000 requests Request per second: 913.0 [#/s] (mean) Percentage of the requests served within a certain time (ms) 50% 0.99 66% 1.00 75% 1.01 80% 1.02 90% 1.06 95% 1.20 98% 2.12 99% 5.57 100% 12.39 ``` No significant impact to discourse: ``` * before categories_admin: 50: 54 75: 60 90: 70 99: 86 home_admin: 50: 56 75: 65 90: 71 99: 122 topic_admin: 50: 64 75: 73 90: 79 99: 117 categories: 50: 32 75: 33 90: 46 99: 61 home: 50: 34 75: 36 90: 48 99: 56 topic: 50: 40 75: 42 90: 55 99: 83 * after categories_admin: 50: 59 75: 66 90: 80 99: 149 home_admin: 50: 54 75: 58 90: 70 99: 96 topic_admin: 50: 63 75: 66 90: 79 99: 115 categories: 50: 31 75: 32 90: 45 99: 65 home: 50: 34 75: 35 90: 49 99: 58 topic: 50: 40 75: 42 90: 55 99: 78 ``` Modified files: trunk/vm_insnhelper.c Index: vm_insnhelper.c =================================================================== --- vm_insnhelper.c (revision 67428) +++ vm_insnhelper.c (revision 67429) @@ -2796,7 +2796,13 @@ vm_search_super_method(const rb_control_ https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L2796 CC_SET_FASTPATH(cc, vm_call_method_missing, TRUE); } else { - /* TODO: use inline cache */ +#if OPT_INLINE_METHOD_CACHE + if (LIKELY(GET_GLOBAL_METHOD_STATE() == cc->method_state && RCLASS_SERIAL(klass) == cc->class_serial && + ci->mid == cc->me->def->original_id)) + return; + cc->method_state = GET_GLOBAL_METHOD_STATE(); + cc->class_serial = RCLASS_SERIAL(klass); +#endif cc->me = rb_callable_method_entry(klass, ci->mid); CC_SET_FASTPATH(cc, vm_call_super_method, TRUE); } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/