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) --- internal/gc.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'internal/gc.h') 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 */ -- cgit v1.2.3