summaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
authorNARUSE, Yui <naruse@airemix.jp>2021-03-11 20:24:48 +0900
committerNARUSE, Yui <naruse@airemix.jp>2021-03-11 20:24:48 +0900
commitde6072a22edbaab3793cf7f976cc9e0118d0df40 (patch)
tree08c22551519d9c01b02e45c888713dbf6107f855 /vm.c
parent0074ea2d83230e10ab0cd769fff203c13d3c592f (diff)
merge revision(s) abdc634f64a440afcdc7f23c9757d27aab4db8a9,083c5f08ec4e95c9b75810d46f933928327a5ab3,1ecda213668644d656eb0d60654737482447dd92,813fe4c256f89babebb8ab53821ae5eb6bb138c6: [Backport #17497]
remove unused decl --- internal/vm.h | 6 ------ vm_args.c | 2 -- 2 files changed, 8 deletions(-) Check stack overflow in recursive glob_helper [Bug #17162] --- dir.c | 2 ++ internal/vm.h | 1 + vm_eval.c | 10 ++++++++++ 3 files changed, 13 insertions(+) global call-cache cache table for rb_funcall* rb_funcall* (rb_funcall(), rb_funcallv(), ...) functions invokes Ruby's method with given receiver. Ruby 2.7 introduced inline method cache with static memory area. However, Ruby 3.0 reimplemented the method cache data structures and the inline cache was removed. Without inline cache, rb_funcall* searched methods everytime. Most of cases per-Class Method Cache (pCMC) will be helped but pCMC requires VM-wide locking and it hurts performance on multi-Ractor execution, especially all Ractors calls methods with rb_funcall*. This patch introduced Global Call-Cache Cache Table (gccct) for rb_funcall*. Call-Cache was introduced from Ruby 3.0 to manage method cache entry atomically and gccct enables method-caching without VM-wide locking. This table solves the performance issue on multi-ractor execution. [Bug #17497] Ruby-level method invocation does not use gccct because it has inline-method-cache and the table size is limited. Basically rb_funcall* is not used frequently, so 1023 entries can be enough. We will revisit the table size if it is not enough. --- debug_counter.h | 3 + vm.c | 12 +++ vm_callinfo.h | 12 --- vm_core.h | 5 + vm_eval.c | 288 ++++++++++++++++++++++++++++++++++++++++++-------------- vm_insnhelper.c | 11 ++- vm_method.c | 14 ++- 7 files changed, 255 insertions(+), 90 deletions(-) opt_equality_by_mid for rb_equal_opt This patch improves the performance of sequential and parallel execution of rb_equal() (and rb_eql()). [Bug #17497] rb_equal_opt (and rb_eql_opt) does not have own cd and it waste a time to initialize cd. This patch introduces opt_equality_by_mid() to check equality without cd. Furthermore, current master uses "static" cd on rb_equal_opt (and rb_eql_opt) and it hurts CPU caches on multi-thread execution. Now they are gone so there are no bottleneck on parallel execution. --- vm_insnhelper.c | 99 ++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 63 insertions(+), 36 deletions(-)
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/vm.c b/vm.c
index 3920362c00..07271a02f4 100644
--- a/vm.c
+++ b/vm.c
@@ -2589,6 +2589,18 @@ rb_vm_mark(void *ptr)
rb_gc_mark_values(RUBY_NSIG, vm->trap_list.cmd);
rb_id_table_foreach_values(vm->negative_cme_table, vm_mark_negative_cme, NULL);
+ for (i=0; i<VM_GLOBAL_CC_CACHE_TABLE_SIZE; i++) {
+ const struct rb_callcache *cc = vm->global_cc_cache_table[i];
+
+ if (cc != NULL) {
+ if (!vm_cc_invalidated_p(cc)) {
+ rb_gc_mark((VALUE)cc);
+ }
+ else {
+ vm->global_cc_cache_table[i] = NULL;
+ }
+ }
+ }
mjit_mark();
}