summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2023-07-18 10:33:28 -0400
committerPeter Zhu <peter@peterzhu.ca>2023-07-18 14:52:37 -0400
commit4c03eab1aaa30ada3819930ae4e5f22ee534cb23 (patch)
treec843100e69fe0f7a425936818243c1f92c8b6acf /gc.c
parentfe4d906f5fbacbe6e9267af3bd3503339bad63a9 (diff)
Lazily allocate pages at boot
We can just set alloctable pages for the first size pool rather than eagerly allocating pages.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/8092
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/gc.c b/gc.c
index 8658660faf..d96124003f 100644
--- a/gc.c
+++ b/gc.c
@@ -3713,10 +3713,8 @@ Init_heap(void)
objspace->rgengc.oldmalloc_increase_limit = gc_params.oldmalloc_limit_min;
#endif
- heap_add_pages(objspace, &size_pools[0], SIZE_POOL_EDEN_HEAP(&size_pools[0]), gc_params.heap_init_slots / HEAP_PAGE_OBJ_LIMIT);
-
- /* Give other size pools allocatable pages. */
- for (int i = 1; i < SIZE_POOL_COUNT; i++) {
+ /* Set size pools allocatable pages. */
+ for (int i = 0; i < SIZE_POOL_COUNT; i++) {
rb_size_pool_t *size_pool = &size_pools[i];
int multiple = size_pool->slot_size / BASE_SLOT_SIZE;
size_pool->allocatable_pages = gc_params.heap_init_slots * multiple / HEAP_PAGE_OBJ_LIMIT;