summaryrefslogtreecommitdiff
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
authork0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-04-03 16:06:03 +0000
committerk0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-04-03 16:06:03 +0000
commitd147ad6231aebb1d478162fb8e109e0c6a696169 (patch)
tree4a88956ab703d2d2c29b18069ee4336abc591d61 /vm_insnhelper.c
parent2482d1f9e6b770bc5f65ffde97df36066095ff2e (diff)
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 ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r--vm_insnhelper.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index cc35997eae..c2608c7f62 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -2796,7 +2796,13 @@ vm_search_super_method(const rb_control_frame_t *reg_cfp, struct rb_call_info *c
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);
}