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

ruby-changes:28886

From: ko1 <ko1@a...>
Date: Mon, 27 May 2013 01:43:33 +0900 (JST)
Subject: [ruby-changes:28886] ko1:r40938 (trunk): * gc.c (gc_stat): collect shade_operation_count,

ko1	2013-05-27 01:43:21 +0900 (Mon, 27 May 2013)

  New Revision: 40938

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

  Log:
    * gc.c (gc_stat): collect shade_operation_count,
      remembered_sunny_object_count and remembered_shady_object_count
      for each types when RGENGC_PROFILE >= 2.
      They are informative for optimization.

  Modified files:
    trunk/ChangeLog
    trunk/gc.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 40937)
+++ ChangeLog	(revision 40938)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon May 27 01:40:58 2013  Koichi Sasada  <ko1@a...>
+
+	* gc.c (gc_stat): collect shade_operation_count,
+	  remembered_sunny_object_count and remembered_shady_object_count
+	  for each types when RGENGC_PROFILE >= 2.
+	  They are informative for optimization.
+
 Mon May 27 01:15:22 2013  Koichi Sasada  <ko1@a...>
 
 	* hash.c (rb_hash_tbl_raw), internal.h: added.
Index: gc.c
===================================================================
--- gc.c	(revision 40937)
+++ gc.c	(revision 40938)
@@ -330,6 +330,9 @@ typedef struct rb_objspace { https://github.com/ruby/ruby/blob/trunk/gc.c#L330
 	size_t remembered_shady_object_count;
 #if RGENGC_PROFILE >= 2
 	size_t generated_shady_object_count_types[RUBY_T_MASK];
+	size_t shade_operation_count_types[RUBY_T_MASK];
+	size_t remembered_sunny_object_count_types[RUBY_T_MASK];
+	size_t remembered_shady_object_count_types[RUBY_T_MASK];
 #endif
 #endif /* RGENGC_PROFILE */
 #endif /* USE_RGENGC */
@@ -3499,8 +3502,18 @@ rgengc_remember(rb_objspace_t *objspace, https://github.com/ruby/ruby/blob/trunk/gc.c#L3502
 
     if (RGENGC_PROFILE) {
 	if (!rgengc_remembered(objspace, obj)) {
-	    if (RVALUE_SUNNY(obj)) objspace->profile.remembered_sunny_object_count++;
-	    else                   objspace->profile.remembered_shady_object_count++;
+	    if (RVALUE_SUNNY(obj)) {
+		objspace->profile.remembered_sunny_object_count++;
+#if RGENGC_PROFILE >= 2
+		objspace->profile.remembered_sunny_object_count_types[BUILTIN_TYPE(obj)]++;
+#endif
+	    }
+	    else {
+		objspace->profile.remembered_shady_object_count++;
+#if RGENGC_PROFILE >= 2
+		objspace->profile.remembered_shady_object_count_types[BUILTIN_TYPE(obj)]++;
+#endif
+	    }
 	}
     }
 
@@ -3617,6 +3630,9 @@ rb_gc_giveup_promoted_writebarrier(VALUE https://github.com/ruby/ruby/blob/trunk/gc.c#L3630
 
 #if RGENGC_PROFILE
     objspace->profile.shade_operation_count++;
+#if RGENGC_PROFILE >= 2
+    objspace->profile.shade_operation_count_types[BUILTIN_TYPE(obj)]++;
+#endif /* RGENGC_PROFILE >= 2 */
 #endif
 }
 
@@ -3859,6 +3875,20 @@ rb_during_gc(void) https://github.com/ruby/ruby/blob/trunk/gc.c#L3875
     return during_gc;
 }
 
+#if RGENGC_PROFILE >= 2
+static void
+gc_count_add_each_types(VALUE hash, const char *name, size_t *types)
+{
+    VALUE result = rb_hash_new();
+    int i;
+    for (i=0; i<T_MASK; i++) {
+	const char *type = type_name(i, 0);
+	rb_hash_aset(result, ID2SYM(rb_intern(type)), SIZET2NUM(types[i]));
+    }
+    rb_hash_aset(hash, ID2SYM(rb_intern(name)), result);
+}
+#endif
+
 /*
  *  call-seq:
  *     GC.count -> Integer
@@ -3978,13 +4008,10 @@ gc_stat(int argc, VALUE *argv, VALUE sel https://github.com/ruby/ruby/blob/trunk/gc.c#L4008
     rb_hash_aset(hash, sym_remembered_shady_object_count, SIZET2NUM(objspace->profile.remembered_shady_object_count));
 #if RGENGC_PROFILE >= 2
     {
-	VALUE types = rb_hash_new();
-	int i;
-	for (i=0; i<T_MASK; i++) {
-	    const char *type = type_name(i, 0);
-	    rb_hash_aset(types, ID2SYM(rb_intern(type)), SIZET2NUM(objspace->profile.generated_shady_object_count_types[i]));
-	}
-	rb_hash_aset(hash, ID2SYM(rb_intern("generated_shady_object_count_types")), types);
+	gc_count_add_each_types(hash, "generated_shady_object_count_types", objspace->profile.generated_shady_object_count_types);
+	gc_count_add_each_types(hash, "shade_operation_count_types", objspace->profile.shade_operation_count_types);
+	gc_count_add_each_types(hash, "remembered_sunny_object_count_types", objspace->profile.remembered_sunny_object_count_types);
+	gc_count_add_each_types(hash, "remembered_shady_object_count_types", objspace->profile.remembered_shady_object_count_types);
     }
 #endif
 #endif /* RGENGC_PROFILE */

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

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