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

ruby-changes:28857

From: ko1 <ko1@a...>
Date: Fri, 24 May 2013 15:53:02 +0900 (JST)
Subject: [ruby-changes:28857] ko1:r40909 (trunk): * gc.c (after_gc_sweep, garbage_collect_body): do major GC (full GC)

ko1	2013-05-24 15:52:38 +0900 (Fri, 24 May 2013)

  New Revision: 40909

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=40909

  Log:
    * gc.c (after_gc_sweep, garbage_collect_body): do major GC (full GC)
      before extending heaps.
      TODO: do major GC when there are many old (promoted) objects.
    * gc.c (after_gc_sweep): remove TODO comments.

  Modified files:
    trunk/ChangeLog
    trunk/gc.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 40908)
+++ ChangeLog	(revision 40909)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri May 24 15:48:18 2013  Koichi Sasada  <ko1@a...>
+
+	* gc.c (after_gc_sweep, garbage_collect_body): do major GC (full GC)
+	  before extending heaps.
+	  TODO: do major GC when there are many old (promoted) objects.
+
+	* gc.c (after_gc_sweep): remove TODO comments.
+
 Fri May 24 11:04:00 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* configure.in (LIBRUBY_RPATHFLAGS): do not append -L option with
Index: gc.c
===================================================================
--- gc.c	(revision 40908)
+++ gc.c	(revision 40909)
@@ -352,6 +352,11 @@ typedef struct rb_objspace { https://github.com/ruby/ruby/blob/trunk/gc.c#L352
     struct {
 	int during_minor_gc;
 	int parent_object_is_promoted;
+	/* need_major_gc is setting at:
+	 *  * free_num < free_min @ after_gc_sweep()
+	 */
+	int need_major_gc;
+	int done_major_gc;
 
 	/* for check mode */
 	VALUE parent_object;
@@ -2247,8 +2252,14 @@ after_gc_sweep(rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/gc.c#L2252
 		  objspace->heap.free_num, objspace->heap.free_min);
 
     if (objspace->heap.free_num < objspace->heap.free_min) {
-        set_heaps_increment(objspace);
-        heaps_increment(objspace);
+	if (has_free_object && objspace->rgengc.done_major_gc == FALSE) {
+	    objspace->rgengc.need_major_gc = TRUE;
+	}
+	else {
+	    objspace->rgengc.done_major_gc = FALSE;
+	    set_heaps_increment(objspace);
+	    heaps_increment(objspace);
+	}
     }
 
     inc = ATOMIC_SIZE_EXCHANGE(malloc_increase, 0);
@@ -2315,10 +2326,9 @@ gc_sweep(rb_objspace_t *objspace, int im https://github.com/ruby/ruby/blob/trunk/gc.c#L2326
     }
 
     if (!has_free_object) {
-	/* there is no freespace after slot_sweep() */
-	/* TODO: [RGENGC] Should do major GC before adding hepas */
+	/* there is no free after slot_sweep() */
 	set_heaps_increment(objspace);
-	if (!heaps_increment(objspace)) {
+	if (!heaps_increment(objspace)) { /* can't allocate additional free objects */
 	    during_gc = 0;
 	    rb_memerror();
 	}
@@ -3689,7 +3699,7 @@ garbage_collect_body(rb_objspace_t *objs https://github.com/ruby/ruby/blob/trunk/gc.c#L3699
     int minor_gc;
 
     if (ruby_gc_stress && !ruby_disable_gc_stress) {
-	minor_gc = TRUE;
+	minor_gc = FALSE;
 	immediate_sweep = TRUE;
     }
     else {
@@ -3697,8 +3707,14 @@ garbage_collect_body(rb_objspace_t *objs https://github.com/ruby/ruby/blob/trunk/gc.c#L3707
 	    minor_gc = FALSE;
 	}
 	else {
-	    /* TODO: count old object size and so on */
-	    minor_gc = TRUE;
+	    if (objspace->rgengc.need_major_gc) {
+		objspace->rgengc.done_major_gc = TRUE;
+		objspace->rgengc.need_major_gc = FALSE;
+		minor_gc = FALSE;
+	    }
+	    else {
+		minor_gc = TRUE;
+	    }
 	}
     }
 

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

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