diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-06-21 05:17:40 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-06-21 05:17:40 +0000 |
commit | e35f127403979e2b61e38402155b1e5d94910c6a (patch) | |
tree | 471f2692b9bf788c4e1211eb3d94e09bc0182666 | |
parent | 4a113cd3cb1eb33811532181a9c3f2cb0f666a09 (diff) | |
download | ruby-e35f127403979e2b61e38402155b1e5d94910c6a.tar.gz |
* gc.c: fix to use total_allocated_object_num and heaps_used
at the GC time for profiler.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | gc.c | 10 |
2 files changed, 12 insertions, 3 deletions
@@ -1,3 +1,8 @@ +Fri Jun 21 14:15:08 2013 Koichi Sasada <ko1@atdot.net> + + * 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@atdot.net> * gc.c: RGENGC_CHECK_MODE should be 0. @@ -355,6 +355,8 @@ typedef struct rb_objspace { /* 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 *objspace, int full_mark, int immediate_sweep 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 *objspace) 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 |