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

ruby-changes:33844

From: ko1 <ko1@a...>
Date: Mon, 12 May 2014 19:57:18 +0900 (JST)
Subject: [ruby-changes:33844] ko1:r45925 (trunk): * gc.c: count young object correctly and show it in GC.stat

ko1	2014-05-12 19:57:11 +0900 (Mon, 12 May 2014)

  New Revision: 45925

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

  Log:
    * gc.c: count young object correctly and show it in GC.stat
      on RGENGC_AGE2_PROMOTION.
    * gc.c (RVALUE_PROMOTE_YOUNG): decrement young object count on
      YOUNG->OLD.
    * gc.c (obj_free): decrement young object count when young object
      freed.
    * gc.c (gc_marks): should not clear young object count.
    * gc.c (gc_stat_internal): GC.stat :young_object information.

  Modified files:
    trunk/ChangeLog
    trunk/gc.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 45924)
+++ ChangeLog	(revision 45925)
@@ -1,3 +1,18 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon May 12 19:52:11 2014  Koichi Sasada  <ko1@a...>
+
+	* gc.c: count young object correctly and show it in GC.stat
+	  on RGENGC_AGE2_PROMOTION.
+
+	* gc.c (RVALUE_PROMOTE_YOUNG): decrement young object count on
+	  YOUNG->OLD.
+
+	* gc.c (obj_free): decrement young object count when young object
+	  freed.
+
+	* gc.c (gc_marks): should not clear young object count.
+
+	* gc.c (gc_stat_internal): GC.stat :young_object information.
+
 Mon May 12 01:30:59 2014  Tanaka Akira  <akr@f...>
 
 	* ext/socket/ifaddr.c (IS_IFADDRS): Unused macro removed.
Index: gc.c
===================================================================
--- gc.c	(revision 45924)
+++ gc.c	(revision 45925)
@@ -844,6 +844,8 @@ RVALUE_PROMOTE_YOUNG(rb_objspace_t *objs https://github.com/ruby/ruby/blob/trunk/gc.c#L844
 
     if (RGENGC_CHECK_MODE && !RVALUE_YOUNG_P(obj)) rb_bug("RVALUE_PROMOTE_YOUNG: %p (%s) is not young object.", (void *)obj, obj_type_name(obj));
     MARK_IN_BITMAP(GET_HEAP_OLDGEN_BITS(obj), obj);
+
+    objspace->rgengc.young_object_count--;
     objspace->rgengc.old_object_count++;
 
     check_gen_consistency(obj);
@@ -1531,8 +1533,14 @@ obj_free(rb_objspace_t *objspace, VALUE https://github.com/ruby/ruby/blob/trunk/gc.c#L1533
     }
 
 #if USE_RGENGC
-    if (MARKED_IN_BITMAP(GET_HEAP_OLDGEN_BITS(obj),obj))
+#if RGENGC_AGE2_PROMOTION
+    if (RVALUE_YOUNG_P(obj)) {
+	objspace->rgengc.young_object_count--;
+    }
+#endif
+    if (MARKED_IN_BITMAP(GET_HEAP_OLDGEN_BITS(obj),obj)) {
 	CLEAR_IN_BITMAP(GET_HEAP_OLDGEN_BITS(obj),obj);
+    }
 #endif
 
     switch (BUILTIN_TYPE(obj)) {
@@ -4554,9 +4562,6 @@ gc_marks(rb_objspace_t *objspace, int fu https://github.com/ruby/ruby/blob/trunk/gc.c#L4562
 	if (full_mark == TRUE) { /* major/full GC */
 	    objspace->rgengc.remembered_shady_object_count = 0;
 	    objspace->rgengc.old_object_count = 0;
-#if RGENGC_AGE2_PROMOTION
-	    objspace->rgengc.young_object_count = 0;
-#endif
 
 	    gc_marks_body(objspace, TRUE);
 	    {
@@ -5426,6 +5431,9 @@ gc_stat_internal(VALUE hash_or_sym, size https://github.com/ruby/ruby/blob/trunk/gc.c#L5431
     static VALUE sym_minor_gc_count, sym_major_gc_count;
     static VALUE sym_remembered_shady_object, sym_remembered_shady_object_limit;
     static VALUE sym_old_object, sym_old_object_limit;
+#if RGENGC_AGE2_PROMOTION
+    static VALUE sym_young_object;
+#endif
 #if RGENGC_ESTIMATE_OLDMALLOC
     static VALUE sym_oldmalloc_increase, sym_oldmalloc_limit;
 #endif
@@ -5469,6 +5477,9 @@ gc_stat_internal(VALUE hash_or_sym, size https://github.com/ruby/ruby/blob/trunk/gc.c#L5477
 	S(remembered_shady_object_limit);
 	S(old_object);
 	S(old_object_limit);
+#if RGENGC_AGE2_PROMOTION
+	S(young_object);
+#endif
 #if RGENGC_ESTIMATE_OLDMALLOC
 	S(oldmalloc_increase);
 	S(oldmalloc_limit);
@@ -5515,6 +5526,9 @@ gc_stat_internal(VALUE hash_or_sym, size https://github.com/ruby/ruby/blob/trunk/gc.c#L5526
     SET(remembered_shady_object_limit, objspace->rgengc.remembered_shady_object_limit);
     SET(old_object, objspace->rgengc.old_object_count);
     SET(old_object_limit, objspace->rgengc.old_object_limit);
+#if RGENGC_AGE2_PROMOTION
+    SET(young_object, objspace->rgengc.young_object_count);
+#endif
 #if RGENGC_ESTIMATE_OLDMALLOC
     SET(oldmalloc_increase, objspace->rgengc.oldmalloc_increase);
     SET(oldmalloc_limit, objspace->rgengc.oldmalloc_increase_limit);

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

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