[前][次][番号順一覧][スレッド一覧]

ruby-changes:68053

From: Peter <ko1@a...>
Date: Mon, 20 Sep 2021 22:02:08 +0900 (JST)
Subject: [ruby-changes:68053] 9770bf23b7 (master): Fix malloc_increase is not correctly calculated

https://git.ruby-lang.org/ruby.git/commit/?id=9770bf23b7

From 9770bf23b7a273246b9a6b084e79a8fb6fc1af11 Mon Sep 17 00:00:00 2001
From: Peter Zhu <peter.zhu@s...>
Date: Fri, 17 Sep 2021 14:38:06 -0400
Subject: Fix malloc_increase is not correctly calculated

Commit 123eeb1c1a904923754ce65148dbef045b56e083 added incremental GC
which moved resetting malloc_increase, oldmalloc_increase to before
marking. However, during_minor_gc is not set until gc_marks_start. So
the value will be from the last GC run, rather than the current one.
Before the incremental GC commit, this code was in gc_before_sweep
which ran before sweep (after marking) so the value during_minor_gc
was correct.
---
 gc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gc.c b/gc.c
index 57a757d..40c035f 100644
--- a/gc.c
+++ b/gc.c
@@ -8881,7 +8881,7 @@ ready_to_gc(rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/gc.c#L8881
 }
 
 static void
-gc_reset_malloc_info(rb_objspace_t *objspace)
+gc_reset_malloc_info(rb_objspace_t *objspace, bool full_mark)
 {
     gc_prof_set_malloc_info(objspace);
     {
@@ -8915,7 +8915,7 @@ gc_reset_malloc_info(rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/gc.c#L8915
 
     /* reset oldmalloc info */
 #if RGENGC_ESTIMATE_OLDMALLOC
-    if (!is_full_marking(objspace)) {
+    if (!full_mark) {
 	if (objspace->rgengc.oldmalloc_increase > objspace->rgengc.oldmalloc_increase_limit) {
 	    objspace->rgengc.need_major_gc |= GPR_FLAG_MAJOR_BY_OLDMALLOC;
 	    objspace->rgengc.oldmalloc_increase_limit =
@@ -9071,7 +9071,7 @@ gc_start(rb_objspace_t *objspace, unsigned int reason) https://github.com/ruby/ruby/blob/trunk/gc.c#L9071
     objspace->profile.total_allocated_objects_at_gc_start = objspace->total_allocated_objects;
     objspace->profile.heap_used_at_gc_start = heap_allocated_pages;
     gc_prof_setup_new_record(objspace, reason);
-    gc_reset_malloc_info(objspace);
+    gc_reset_malloc_info(objspace, do_full_mark);
     rb_transient_heap_start_marking(do_full_mark);
 
     gc_event_hook(objspace, RUBY_INTERNAL_EVENT_GC_START, 0 /* TODO: pass minor/immediate flag? */);
-- 
cgit v1.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]