summaryrefslogtreecommitdiff
path: root/class.c
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2021-11-19 14:51:58 -0500
committerPeter Zhu <peter@peterzhu.ca>2021-11-23 10:51:27 -0500
commit9aded89f4071a8afb79326701789241f1da12f82 (patch)
tree4869f264a95718d7c6882564cf0d19a913fe952e /class.c
parentc14f230b26aa4f8abe9ecf3814cfebbe584d77c9 (diff)
downloadruby-9aded89f4071a8afb79326701789241f1da12f82.tar.gz
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)
Diffstat (limited to 'class.c')
-rw-r--r--class.c4
1 files changed, 3 insertions, 1 deletions
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