From 9aded89f4071a8afb79326701789241f1da12f82 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Fri, 19 Nov 2021 14:51:58 -0500 Subject: Speed up Ractors for Variable Width Allocation This commit adds a Ractor cache for every size pool. Previously, all VWA allocated objects used the slowpath and locked the VM. On a micro-benchmark that benchmarks String allocation: VWA turned off: 29.196591 0.889709 30.086300 ( 9.434059) VWA before this commit: 29.279486 41.477869 70.757355 ( 12.527379) VWA after this commit: 16.782903 0.557117 17.340020 ( 4.255603) --- class.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'class.c') diff --git a/class.c b/class.c index 6ad64a6efe..f1e8953f81 100644 --- a/class.c +++ b/class.c @@ -203,7 +203,9 @@ class_alloc(VALUE flags, VALUE klass) RVARGC_NEWOBJ_OF(obj, struct RClass, klass, (flags & T_MASK) | FL_PROMOTED1 /* start from age == 2 */ | (RGENGC_WB_PROTECTED_CLASS ? FL_WB_PROTECTED : 0), alloc_size); -#if !USE_RVARGC +#if USE_RVARGC + memset(RCLASS_EXT(obj), 0, sizeof(rb_classext_t)); +#else obj->ptr = ZALLOC(rb_classext_t); #endif -- cgit v1.2.1