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

ruby-changes:53145

From: ko1 <ko1@a...>
Date: Thu, 25 Oct 2018 07:17:13 +0900 (JST)
Subject: [ruby-changes:53145] ko1:r65359 (trunk): add new debug_counters for GC.

ko1	2018-10-25 07:17:03 +0900 (Thu, 25 Oct 2018)

  New Revision: 65359

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65359

  Log:
    add new debug_counters for GC.
    
    * debug_counter.h: add new debug counters to count GC.

  Modified files:
    trunk/debug_counter.h
    trunk/gc.c
Index: gc.c
===================================================================
--- gc.c	(revision 65358)
+++ gc.c	(revision 65359)
@@ -6536,6 +6536,23 @@ gc_start(rb_objspace_t *objspace, int re https://github.com/ruby/ruby/blob/trunk/gc.c#L6536
 	      reason,
 	      do_full_mark, !is_incremental_marking(objspace), objspace->flags.immediate_sweep);
 
+#if USE_DEBUG_COUNTER
+    RB_DEBUG_COUNTER_INC(gc_count);
+    if (reason & GPR_FLAG_MAJOR_MASK) {
+        (void)RB_DEBUG_COUNTER_INC_IF(gc_major_nofree, reason & GPR_FLAG_MAJOR_BY_NOFREE);
+        (void)RB_DEBUG_COUNTER_INC_IF(gc_major_oldgen, reason & GPR_FLAG_MAJOR_BY_OLDGEN);
+        (void)RB_DEBUG_COUNTER_INC_IF(gc_major_shady,  reason & GPR_FLAG_MAJOR_BY_SHADY);
+        (void)RB_DEBUG_COUNTER_INC_IF(gc_major_force,  reason & GPR_FLAG_MAJOR_BY_FORCE);
+    }
+    else {
+        (void)RB_DEBUG_COUNTER_INC_IF(gc_minor_newobj, reason & GPR_FLAG_NEWOBJ);
+        (void)RB_DEBUG_COUNTER_INC_IF(gc_minor_malloc, reason & GPR_FLAG_MALLOC);
+        (void)RB_DEBUG_COUNTER_INC_IF(gc_minor_method, reason & GPR_FLAG_METHOD);
+        (void)RB_DEBUG_COUNTER_INC_IF(gc_minor_capi,   reason & GPR_FLAG_CAPI);
+        (void)RB_DEBUG_COUNTER_INC_IF(gc_minor_stress, reason & GPR_FLAG_NEWOBJ);
+    }
+#endif
+
     objspace->profile.count++;
     objspace->profile.latest_gc_info = reason;
     objspace->profile.total_allocated_objects_at_gc_start = objspace->total_allocated_objects;
Index: debug_counter.h
===================================================================
--- debug_counter.h	(revision 65358)
+++ debug_counter.h	(revision 65359)
@@ -101,6 +101,25 @@ RB_DEBUG_COUNTER(lvar_set) https://github.com/ruby/ruby/blob/trunk/debug_counter.h#L101
 RB_DEBUG_COUNTER(lvar_set_dynamic)
 RB_DEBUG_COUNTER(lvar_set_slowpath)
 
+/* GC counts:
+ *
+ * * count: simple count
+ * * _minor: minor gc
+ * * _major: major gc
+ * * other suffix is corresponding to last_gc_info or
+ *   gc_profile_record_flag in gc.c.
+ */
+RB_DEBUG_COUNTER(gc_count)
+RB_DEBUG_COUNTER(gc_minor_newobj)
+RB_DEBUG_COUNTER(gc_minor_malloc)
+RB_DEBUG_COUNTER(gc_minor_method)
+RB_DEBUG_COUNTER(gc_minor_capi)
+RB_DEBUG_COUNTER(gc_minor_stress)
+RB_DEBUG_COUNTER(gc_major_nofree)
+RB_DEBUG_COUNTER(gc_major_oldgen)
+RB_DEBUG_COUNTER(gc_major_shady)
+RB_DEBUG_COUNTER(gc_major_force)
+
 /* object allocation counts:
  *
  * * obj_newobj: newobj counts

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

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