summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-06-09 11:43:23 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-06-09 11:43:23 +0000
commit5b2a7458108fa13ac9ef194d544792a82243f5ff (patch)
tree474108c635224bb3ddc9015d19784b04afc28816
parent029fd365df84c4bb40fba4a9b7f89215a0eb3781 (diff)
* gc.c: change full GC timing to keep lower memory usage.
Extend heap only at (1) after major GC or (2) after several (two times, at current) minor GC Details in https://bugs.ruby-lang.org/issues/9607#note-9 [Bug #9607] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46387 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog12
-rw-r--r--gc.c18
2 files changed, 22 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 43aa36b308..95822ec3a5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+Mon Jun 9 20:40:48 2014 Koichi Sasada <ko1@atdot.net>
+
+ * gc.c: change full GC timing to keep lower memory usage.
+
+ Extend heap only at
+ (1) after major GC
+ or
+ (2) after several (two times, at current) minor GC
+
+ Details in https://bugs.ruby-lang.org/issues/9607#note-9
+ [Bug #9607]
+
Mon Jun 9 16:01:41 2014 Masahiro Ide <imasahiro9@gmail.com>
* gc.c (gcdebug_sentinel): fix typo, "sentinel" not "sential".
diff --git a/gc.c b/gc.c
index 1c0c3207b8..c807d5119a 100644
--- a/gc.c
+++ b/gc.c
@@ -531,6 +531,9 @@ typedef struct rb_objspace {
int parent_object_is_old;
int need_major_gc;
+
+ size_t last_major_gc;
+
size_t remembered_shady_object_count;
size_t remembered_shady_object_limit;
size_t old_object_count;
@@ -3035,15 +3038,13 @@ gc_after_sweep(rb_objspace_t *objspace)
(int)heap->total_slots, (int)heap_pages_swept_slots, (int)heap_pages_min_free_slots);
if (heap_pages_swept_slots < heap_pages_min_free_slots) {
- heap_set_increment(objspace, heap_extend_pages(objspace));
- heap_increment(objspace, heap);
-
-#if USE_RGENGC
- if (objspace->rgengc.remembered_shady_object_count + objspace->rgengc.old_object_count > (heap_pages_length * HEAP_OBJ_LIMIT) / 2) {
- /* if [old]+[remembered shady] > [all object count]/2, then do major GC */
- objspace->rgengc.need_major_gc = GPR_FLAG_MAJOR_BY_RESCAN;
+ if (objspace->rgengc.during_minor_gc && objspace->profile.count - objspace->rgengc.last_major_gc > 2 /* magic number */) {
+ objspace->rgengc.need_major_gc = GPR_FLAG_MAJOR_BY_NOFREE;
+ }
+ else {
+ heap_set_increment(objspace, heap_extend_pages(objspace));
+ heap_increment(objspace, heap);
}
-#endif
}
gc_prof_set_heap_info(objspace);
@@ -4256,6 +4257,7 @@ gc_marks_body(rb_objspace_t *objspace, int full_mark)
objspace->profile.major_gc_count++;
objspace->rgengc.remembered_shady_object_count = 0;
objspace->rgengc.old_object_count = 0;
+ objspace->rgengc.last_major_gc = objspace->profile.count;
rgengc_mark_and_rememberset_clear(objspace, heap_eden);
}
#endif