ruby-changes:29466
From: ko1 <ko1@a...>
Date: Fri, 21 Jun 2013 14:17:51 +0900 (JST)
Subject: [ruby-changes:29466] ko1:r41518 (trunk): * gc.c: fix to use total_allocated_object_num and heaps_used
ko1 2013-06-21 14:17:40 +0900 (Fri, 21 Jun 2013) New Revision: 41518 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41518 Log: * gc.c: fix to use total_allocated_object_num and heaps_used at the GC time for profiler. Modified files: trunk/ChangeLog trunk/gc.c Index: ChangeLog =================================================================== --- ChangeLog (revision 41517) +++ ChangeLog (revision 41518) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Jun 21 14:15:08 2013 Koichi Sasada <ko1@a...> + + * gc.c: fix to use total_allocated_object_num and heaps_used + at the GC time for profiler. + Fri Jun 21 12:35:35 2013 Koichi Sasada <ko1@a...> * gc.c: RGENGC_CHECK_MODE should be 0. Index: gc.c =================================================================== --- gc.c (revision 41517) +++ gc.c (revision 41518) @@ -355,6 +355,8 @@ typedef struct rb_objspace { https://github.com/ruby/ruby/blob/trunk/gc.c#L355 /* temporary profiling space */ double gc_sweep_start_time; + size_t total_allocated_object_num_at_gc_start; + size_t heaps_used_at_gc_start; } profile; struct gc_list *global_list; size_t count; @@ -3957,6 +3959,8 @@ garbage_collect_body(rb_objspace_t *objs https://github.com/ruby/ruby/blob/trunk/gc.c#L3959 if (GC_NOTIFY) fprintf(stderr, "start garbage_collect(%d, %d, %d)\n", full_mark, immediate_sweep, reason); objspace->count++; + 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 | (minor_gc ? GPR_FLAG_MINOR : 0)); @@ -5099,11 +5103,11 @@ gc_prof_set_malloc_info(rb_objspace_t *o https://github.com/ruby/ruby/blob/trunk/gc.c#L5103 static inline void gc_prof_set_heap_info(rb_objspace_t *objspace, gc_profile_record *record) { - size_t live = objspace_live_num(objspace); - size_t total = heaps_used * HEAP_OBJ_LIMIT; + 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 = heaps_used; + record->heap_use_slots = objspace->profile.heaps_used_at_gc_start; record->heap_live_objects = live; record->heap_free_objects = total - live; #endif -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/