From 9694416c061ebf315a18cd4679730cc72744c5dc Mon Sep 17 00:00:00 2001 From: tarui Date: Sun, 23 Jun 2013 22:58:01 +0000 Subject: [PATCH] * 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ gc.c | 30 +++++++++++++++++++++--------- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 88e8ebbda7..79e696e6cf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon Jun 24 07:57:18 2013 Masaya Tarui + + * 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 * array.c: Return value in Array overview example found by @PragTob diff --git a/gc.c b/gc.c index fa64bf9f04..9578070118 100644 --- a/gc.c +++ b/gc.c @@ -530,7 +530,8 @@ static void gc_mark_maybe(rb_objspace_t *objspace, VALUE ptr); 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) #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) 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 *objspace, int full_mark, int immediate_sweep 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) } 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 *objspace, int reason) } 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 *objspace) 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 }