From 2d581d6c2a7d93965b6e4679bb4b8a867feef7d8 Mon Sep 17 00:00:00 2001 From: ko1 Date: Wed, 10 Sep 2014 02:13:41 +0000 Subject: [PATCH] * gc.c (gc_stat_internal): support: * total_allocated_pages * total_freed_pages ref: [Feature #9924] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47490 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ gc.c | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/ChangeLog b/ChangeLog index 7284428604..ec6240c3ea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Wed Sep 10 11:12:25 2014 Koichi Sasada + + * gc.c (gc_stat_internal): support: + * total_allocated_pages + * total_freed_pages + ref: [Feature #9924] + Wed Sep 10 10:48:04 2014 Koichi Sasada * test/ruby/test_gc.rb: catch up last fix. diff --git a/gc.c b/gc.c index 2244259eb9..4bba6ec7d8 100644 --- a/gc.c +++ b/gc.c @@ -557,6 +557,8 @@ typedef struct rb_objspace { /* basic statistics */ size_t count; size_t total_freed_objects; + size_t total_allocated_pages; + size_t total_freed_pages; } profile; struct gc_list *global_list; @@ -1299,6 +1301,7 @@ static void heap_page_free(rb_objspace_t *objspace, struct heap_page *page) { heap_allocated_pages--; + objspace->profile.total_freed_pages++; aligned_free(page->body); free(page); } @@ -1383,6 +1386,8 @@ heap_page_allocate(rb_objspace_t *objspace) heap_pages_sorted[hi] = page; heap_allocated_pages++; + objspace->profile.total_allocated_pages++; + if (RGENGC_CHECK_MODE) assert(heap_allocated_pages <= heap_pages_sorted_length); /* adjust obj_limit (object number available in this page) */ @@ -6253,6 +6258,7 @@ gc_stat_internal(VALUE hash_or_sym) static VALUE sym_heap_available_slots, sym_heap_live_slots, sym_heap_free_slots, sym_heap_final_slots; static VALUE sym_heap_marked_slots, sym_heap_swept_slots; static VALUE sym_heap_eden_pages, sym_heap_tomb_pages; + static VALUE sym_total_allocated_pages, sym_total_freed_pages; static VALUE sym_total_allocated_objects, sym_total_freed_objects; static VALUE sym_malloc_increase, sym_malloc_limit; #if USE_RGENGC @@ -6296,6 +6302,8 @@ gc_stat_internal(VALUE hash_or_sym) S(heap_swept_slots); S(heap_eden_pages); S(heap_tomb_pages); + S(total_allocated_pages); + S(total_freed_pages); S(total_allocated_objects); S(total_freed_objects); S(malloc_increase); @@ -6343,6 +6351,8 @@ gc_stat_internal(VALUE hash_or_sym) SET(heap_swept_slots, heap_pages_swept_slots); SET(heap_eden_pages, heap_eden->page_length); SET(heap_tomb_pages, heap_tomb->page_length); + SET(total_allocated_pages, objspace->profile.total_allocated_pages); + SET(total_freed_pages, objspace->profile.total_freed_pages); SET(total_allocated_objects, objspace->total_allocated_objects); SET(total_freed_objects, objspace->profile.total_freed_objects); SET(malloc_increase, malloc_increase);