From 51268be7feace6a6547f8be72d6baf9023b08f2b Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 23 Oct 2020 16:13:11 -0700 Subject: [PATCH] When allocating new pages, add them to the end of the linked list When we allocate new pages, allocate them on the end of the linked list. Then when we compact we can move things to the head of the list --- gc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gc.c b/gc.c index a681b0b1fb..306ad0e257 100644 --- a/gc.c +++ b/gc.c @@ -1914,7 +1914,7 @@ heap_add_page(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *page) /* Adding to eden heap during incremental sweeping is forbidden */ GC_ASSERT(!(heap == heap_eden && heap->sweeping_page)); page->flags.in_tomb = (heap == heap_tomb); - list_add(&heap->pages, &page->page_node); + list_add_tail(&heap->pages, &page->page_node); heap->total_pages++; heap->total_slots += page->total_slots; } @@ -5036,7 +5036,7 @@ gc_sweep_step(rb_objspace_t *objspace, rb_heap_t *heap) do { int free_slots = gc_page_sweep(objspace, heap, sweep_page); - heap->sweeping_page = list_next(&heap->pages, sweep_page, page_node); + heap->sweeping_page = list_next(&heap->pages, sweep_page, page_node); if (sweep_page->final_slots + free_slots == sweep_page->total_slots && heap_pages_freeable_pages > 0 &&