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

ruby-changes:29500

From: ko1 <ko1@a...>
Date: Sat, 22 Jun 2013 07:29:27 +0900 (JST)
Subject: [ruby-changes:29500] ko1:r41552 (trunk): * gc.c (gc_prof_set_heap_info, after_gc_sweep): call

ko1	2013-06-22 07:29:09 +0900 (Sat, 22 Jun 2013)

  New Revision: 41552

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

  Log:
    * gc.c (gc_prof_set_heap_info, after_gc_sweep): call
      gc_prof_set_heap_info() just after sweeping to calculate
      live object number correctly.
      (live object number = total generated number (before marking) -
                            total freed number (after sweeping))
    * gc.c (gc_marks): record `oldgen_object_count' into current profile`
      record directly.
    * gc.c (rgengc_rememberset_mark): same for remembered_normal_objects
      and remembered_shady_objects.

  Modified files:
    trunk/ChangeLog
    trunk/gc.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 41551)
+++ ChangeLog	(revision 41552)
@@ -1,3 +1,17 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Jun 22 07:20:30 2013  Koichi Sasada  <ko1@a...>
+
+	* gc.c (gc_prof_set_heap_info, after_gc_sweep): call
+	  gc_prof_set_heap_info() just after sweeping to calculate
+	  live object number correctly.
+	  (live object number = total generated number (before marking) -
+                                total freed number (after sweeping))
+
+	* gc.c (gc_marks): record `oldgen_object_count' into current profile`
+	  record directly.
+
+	* gc.c (rgengc_rememberset_mark): same for remembered_normal_objects
+	  and remembered_shady_objects.
+
 Sat Jun 22 06:46:04 2013  Koichi Sasada  <ko1@a...>
 
 	* gc.c (rb_objspace::profile): rename rb_objspace::profile::record to
Index: gc.c
===================================================================
--- gc.c	(revision 41551)
+++ gc.c	(revision 41552)
@@ -350,9 +350,6 @@ typedef struct rb_objspace { https://github.com/ruby/ruby/blob/trunk/gc.c#L350
 	size_t remembered_normal_object_count;
 	size_t remembered_shady_object_count;
 
-	/* temporal profiling space */
-	size_t remembered_normal_objects;
-	size_t remembered_shady_objects;
 #if RGENGC_PROFILE >= 2
 	size_t generated_normal_object_count_types[RUBY_T_MASK];
 	size_t generated_shady_object_count_types[RUBY_T_MASK];
@@ -532,6 +529,8 @@ static inline void gc_prof_mark_timer_st https://github.com/ruby/ruby/blob/trunk/gc.c#L529
 static inline void gc_prof_sweep_timer_start(rb_objspace_t *);
 static inline void gc_prof_sweep_timer_stop(rb_objspace_t *);
 static inline void gc_prof_set_malloc_info(rb_objspace_t *);
+static inline void gc_prof_set_heap_info(rb_objspace_t *);
+
 #define gc_prof_record(objspace) (objspace)->profile.current_record
 
 static const char *obj_type_name(VALUE obj);
@@ -2320,10 +2319,7 @@ after_gc_sweep(rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/gc.c#L2319
 {
     size_t inc;
 
-    rgengc_report(1, objspace, "after_gc_sweep\n");
-
-    gc_prof_set_malloc_info(objspace);
-    rgengc_report(5, objspace, "after_gc_sweep: objspace->heap.free_num: %d, objspace->heap.free_min: %d\n",
+    rgengc_report(1, objspace, "after_gc_sweep: objspace->heap.free_num: %d, objspace->heap.free_min: %d\n",
 		  objspace->heap.free_num, objspace->heap.free_min);
 
     if (objspace->heap.free_num < objspace->heap.free_min) {
@@ -2350,6 +2346,9 @@ after_gc_sweep(rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/gc.c#L2346
 
     free_unused_heaps(objspace);
 
+    gc_prof_set_malloc_info(objspace);
+    gc_prof_set_heap_info(objspace);
+
     gc_event_hook(objspace, RUBY_INTERNAL_EVENT_GC_END, 0 /* TODO: pass minor/immediate flag? */);
 }
 
@@ -3614,6 +3613,14 @@ gc_marks(rb_objspace_t *objspace, int mi https://github.com/ruby/ruby/blob/trunk/gc.c#L3613
 		gc_marks_body(objspace, TRUE);
 	    }
 	}
+
+#if RGENGC_PROFILE > 0
+    if (gc_prof_record(objspace)) {
+	gc_profile_record *record = gc_prof_record(objspace);
+	record->oldgen_objects = objspace->rgengc.oldgen_object_count;
+    }
+#endif
+
 #else /* USE_RGENGC */
 	gc_marks_body(objspace, FALSE);
 #endif
@@ -3736,10 +3743,15 @@ rgengc_rememberset_mark(rb_objspace_t *o https://github.com/ruby/ruby/blob/trunk/gc.c#L3743
     }
 
     rgengc_report(2, objspace, "rgengc_rememberset_mark: clear_count: %"PRIdSIZE", shady_object_count: %"PRIdSIZE"\n", clear_count, shady_object_count);
+
 #if RGENGC_PROFILE > 0
-    objspace->profile.remembered_normal_objects = clear_count;
-    objspace->profile.remembered_shady_objects = shady_object_count;
+    if (gc_prof_record(objspace)) {
+	gc_profile_record *record = gc_prof_record(objspace);
+	record->remembered_normal_objects = clear_count;
+	record->remembered_shady_objects = shady_object_count;
+    }
 #endif
+
     return shady_object_count;
 }
 
@@ -3935,9 +3947,10 @@ garbage_collect_body(rb_objspace_t *objs https://github.com/ruby/ruby/blob/trunk/gc.c#L3947
     if (GC_NOTIFY) fprintf(stderr, "start garbage_collect(%d, %d, %d)\n", full_mark, immediate_sweep, reason);
 
     objspace->count++;
+    gc_event_hook(objspace, RUBY_INTERNAL_EVENT_GC_START, 0 /* TODO: pass minor/immediate flag? */);
+
     objspace->profile.total_allocated_object_num_at_gc_start = objspace->total_allocated_object_num;
     objspace->profile.heaps_used_at_gc_start = heaps_used;
-    gc_event_hook(objspace, RUBY_INTERNAL_EVENT_GC_START, 0 /* TODO: pass minor/immediate flag? */);
 
     gc_prof_timer_start(objspace, reason);
     {
@@ -4889,7 +4902,6 @@ wmap_aref(VALUE self, VALUE wmap) https://github.com/ruby/ruby/blob/trunk/gc.c#L4902
   ------------------------------ GC profiler ------------------------------
 */
 
-static inline void gc_prof_set_heap_info(rb_objspace_t *, gc_profile_record *);
 #define GC_PROFILE_RECORD_DEFAULT_SIZE 100
 
 static double
@@ -4987,7 +4999,6 @@ gc_prof_timer_stop(rb_objspace_t *objspa https://github.com/ruby/ruby/blob/trunk/gc.c#L4999
 	gc_profile_record *record = gc_prof_record(objspace);
 	record->gc_time = elapsed_time_from(record->gc_invoke_time);
 	record->gc_invoke_time -= objspace->profile.invoke_time;
-        gc_prof_set_heap_info(objspace, record);
     }
 }
 
@@ -5076,30 +5087,25 @@ gc_prof_set_malloc_info(rb_objspace_t *o https://github.com/ruby/ruby/blob/trunk/gc.c#L5087
 }
 
 static inline void
-gc_prof_set_heap_info(rb_objspace_t *objspace, gc_profile_record *record)
+gc_prof_set_heap_info(rb_objspace_t *objspace)
 {
-    size_t live = objspace->profile.total_allocated_object_num_at_gc_start - objspace->total_freed_object_num;
-    size_t total = objspace->profile.heaps_used_at_gc_start * HEAP_OBJ_LIMIT;
+    if (objspace->profile.run) {
+	gc_profile_record *record = gc_prof_record(objspace);
+	size_t live = objspace->profile.total_allocated_object_num_at_gc_start - objspace->total_freed_object_num;
+	size_t total = objspace->profile.heaps_used_at_gc_start * HEAP_OBJ_LIMIT;
 
 #if GC_PROFILE_MORE_DETAIL
-    record->heap_use_slots = objspace->profile.heaps_used_at_gc_start;
-    record->heap_live_objects = live;
-    record->heap_free_objects = total - live;
+	record->heap_use_slots = objspace->profile.heaps_used_at_gc_start;
+	record->heap_live_objects = live;
+	record->heap_free_objects = total - live;
 #endif
 
-#if RGENGC_PROFILE > 0
-    record->oldgen_objects = objspace->rgengc.oldgen_object_count;
-    record->remembered_normal_objects = objspace->profile.remembered_normal_objects;
-    record->remembered_shady_objects = objspace->profile.remembered_shady_objects;
-#endif
-
-    record->heap_total_objects = total;
-    record->heap_use_size = live * sizeof(RVALUE);
-    record->heap_total_size = total * sizeof(RVALUE);
+	record->heap_total_objects = total;
+	record->heap_use_size = live * sizeof(RVALUE);
+	record->heap_total_size = total * sizeof(RVALUE);
+    }
 }
 
-
-
 /*
  *  call-seq:
  *    GC::Profiler.clear          -> nil

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

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