summaryrefslogtreecommitdiff
path: root/internal/gc.h
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 /internal/gc.h
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 'internal/gc.h')
-rw-r--r--internal/gc.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/internal/gc.h b/internal/gc.h
index b7b29214cf..baf4f36a10 100644
--- a/internal/gc.h
+++ b/internal/gc.h
@@ -67,9 +67,19 @@ struct rb_objspace; /* in vm_core.h */
rb_obj_write((VALUE)(a), UNALIGNED_MEMBER_ACCESS((VALUE *)(slot)), \
(VALUE)(b), __FILE__, __LINE__)
-typedef struct ractor_newobj_cache {
+#if USE_RVARGC
+# define SIZE_POOL_COUNT 4
+#else
+# define SIZE_POOL_COUNT 1
+#endif
+
+typedef struct ractor_newobj_size_pool_cache {
struct RVALUE *freelist;
struct heap_page *using_page;
+} rb_ractor_newobj_size_pool_cache_t;
+
+typedef struct ractor_newobj_cache {
+ rb_ractor_newobj_size_pool_cache_t size_pool_caches[SIZE_POOL_COUNT];
} rb_ractor_newobj_cache_t;
/* gc.c */