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

ruby-changes:29542

From: tarui <ko1@a...>
Date: Mon, 24 Jun 2013 07:58:12 +0900 (JST)
Subject: [ruby-changes:29542] tarui:r41594 (trunk): * gc.c (after_gc_sweep): Have to record malloc info before reset.

tarui	2013-06-24 07:58:01 +0900 (Mon, 24 Jun 2013)

  New Revision: 41594

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

  Log:
    * gc.c (after_gc_sweep): Have to record malloc info before reset.
    * gc.c (gc_prof_timer_start): Pick out part of new record creation as gc_prof_setup_new_record.
    * gc.c (gc_prof_set_malloc_info): Move point of recording allocation size to front of mark.

  Modified files:
    trunk/ChangeLog
    trunk/gc.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 41593)
+++ ChangeLog	(revision 41594)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Jun 24 07:57:18 2013  Masaya Tarui  <tarui@r...>
+
+	* gc.c (after_gc_sweep): Have to record malloc info before reset.
+	* gc.c (gc_prof_timer_start): Pick out part of new record creation as gc_prof_setup_new_record.
+	* gc.c (gc_prof_set_malloc_info): Move point of recording allocation size to front of mark.
+
 Mon Jun 24 02:53:09 2013  Zachary Scott  <zachary@z...>
 
 	* array.c: Return value in Array overview example found by @PragTob
Index: gc.c
===================================================================
--- gc.c	(revision 41593)
+++ gc.c	(revision 41594)
@@ -530,7 +530,8 @@ static void gc_mark_maybe(rb_objspace_t https://github.com/ruby/ruby/blob/trunk/gc.c#L530
 static void gc_mark_children(rb_objspace_t *objspace, VALUE ptr);
 
 static double getrusage_time(void);
-static inline void gc_prof_timer_start(rb_objspace_t *, int reason);
+static inline void gc_prof_setup_new_record(rb_objspace_t *objspace, int reason);
+static inline void gc_prof_timer_start(rb_objspace_t *);
 static inline void gc_prof_timer_stop(rb_objspace_t *);
 static inline void gc_prof_mark_timer_start(rb_objspace_t *);
 static inline void gc_prof_mark_timer_stop(rb_objspace_t *);
@@ -2342,6 +2343,9 @@ after_gc_sweep(rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/gc.c#L2343
 #endif
     }
 
+    gc_prof_set_malloc_info(objspace);
+    gc_prof_set_heap_info(objspace);
+
     inc = ATOMIC_SIZE_EXCHANGE(malloc_increase, 0);
     inc += malloc_increase2;
     malloc_increase2 = 0;
@@ -2354,8 +2358,6 @@ after_gc_sweep(rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/gc.c#L2358
 
     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? */);
 }
@@ -4028,7 +4030,8 @@ garbage_collect_body(rb_objspace_t *objs https://github.com/ruby/ruby/blob/trunk/gc.c#L4030
     objspace->profile.total_allocated_object_num_at_gc_start = objspace->total_allocated_object_num;
     objspace->profile.heaps_used_at_gc_start = heaps_used;
 
-    gc_prof_timer_start(objspace, reason);
+    gc_prof_setup_new_record(objspace, reason);
+    gc_prof_timer_start(objspace);
     {
 	assert(during_gc > 0);
 	gc_marks(objspace, (reason & GPR_FLAG_MAJOR_MASK) ? FALSE : TRUE);
@@ -5024,7 +5027,7 @@ getrusage_time(void) https://github.com/ruby/ruby/blob/trunk/gc.c#L5027
 }
 
 static inline void
-gc_prof_timer_start(rb_objspace_t *objspace, int reason)
+gc_prof_setup_new_record(rb_objspace_t *objspace, int reason)
 {
     if (objspace->profile.run) {
 	size_t index = objspace->profile.next_index;
@@ -5046,13 +5049,25 @@ gc_prof_timer_start(rb_objspace_t *objsp https://github.com/ruby/ruby/blob/trunk/gc.c#L5049
 	}
 	record = objspace->profile.current_record = &objspace->profile.records[objspace->profile.next_index - 1];
 	MEMZERO(record, gc_profile_record, 1);
+	
+	/* setup before-GC parameter */
+	record->flags = reason | ((ruby_gc_stress && !ruby_disable_gc_stress) ? GPR_FLAG_STRESS : 0);
+#if CALC_EXACT_MALLOC_SIZE
+	record->allocated_size = malloc_allocated_size;
+#endif
+    }
+}
 
+static inline void
+gc_prof_timer_start(rb_objspace_t *objspace)
+{
+    if (objspace->profile.run) {
+	gc_profile_record *record = gc_prof_record(objspace);
 #if GC_PROFILE_MORE_DETAIL
 	record->prepare_time = objspace->profile.prepare_time;
 #endif
 	record->gc_time = 0;
 	record->gc_invoke_time = getrusage_time();
-	record->flags = reason | ((ruby_gc_stress && !ruby_disable_gc_stress) ? GPR_FLAG_STRESS : 0);
     }
 }
 
@@ -5155,9 +5170,6 @@ gc_prof_set_malloc_info(rb_objspace_t *o https://github.com/ruby/ruby/blob/trunk/gc.c#L5170
         gc_profile_record *record = gc_prof_record(objspace);
 	record->allocate_increase = malloc_increase + malloc_increase2;
 	record->allocate_limit = malloc_limit;
-#if CALC_EXACT_MALLOC_SIZE
-	record->allocated_size = malloc_allocated_size;
-#endif
     }
 #endif
 }

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

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