From 77ccfe895cee45d839450e3b09bc1a49137fcfa6 Mon Sep 17 00:00:00 2001 From: "mstarzinger@chromium.org" Date: Mon, 16 Jul 2012 15:17:00 +0000 Subject: [PATCH] Add histogram for total heap fragmentation, don't report fragmentation for new space, and report fragmentation, not usage BUG=none TEST=none Review URL: https://chromiumcodereview.appspot.com/10778009 Patch from Jochen Eisinger . git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12099 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/heap.cc | 48 ++++++++++++++++++++++++++++++------------------ src/v8-counters.h | 4 ++-- 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/src/heap.cc b/src/heap.cc index bfc4620..81339fc 100644 --- a/src/heap.cc +++ b/src/heap.cc @@ -447,26 +447,38 @@ void Heap::GarbageCollectionEpilogue() { isolate_->counters()->number_of_symbols()->Set( symbol_table()->NumberOfElements()); -#define UPDATE_COUNTERS_FOR_SPACE(space) \ - isolate_->counters()->space##_bytes_available()->Set( \ - static_cast(space()->Available())); \ - isolate_->counters()->space##_bytes_committed()->Set( \ - static_cast(space()->CommittedMemory())); \ - isolate_->counters()->space##_bytes_used()->Set( \ - static_cast(space()->SizeOfObjects())); \ - if (space()->CommittedMemory() > 0) { \ - isolate_->counters()->external_fragmentation_##space()->AddSample( \ - static_cast( \ - (space()->SizeOfObjects() * 100) / space()->CommittedMemory())); \ - } + if (CommittedMemory() > 0) { + isolate_->counters()->external_fragmentation_total()->AddSample( + static_cast(100 - (SizeOfObjects() * 100.0) / CommittedMemory())); + } + +#define UPDATE_COUNTERS_FOR_SPACE(space) \ + isolate_->counters()->space##_bytes_available()->Set( \ + static_cast(space()->Available())); \ + isolate_->counters()->space##_bytes_committed()->Set( \ + static_cast(space()->CommittedMemory())); \ + isolate_->counters()->space##_bytes_used()->Set( \ + static_cast(space()->SizeOfObjects())); +#define UPDATE_FRAGMENTATION_FOR_SPACE(space) \ + if (space()->CommittedMemory() > 0) { \ + isolate_->counters()->external_fragmentation_##space()->AddSample( \ + static_cast(100 - \ + (space()->SizeOfObjects() * 100.0) / space()->CommittedMemory())); \ + } +#define UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(space) \ + UPDATE_COUNTERS_FOR_SPACE(space) \ + UPDATE_FRAGMENTATION_FOR_SPACE(space) + UPDATE_COUNTERS_FOR_SPACE(new_space) - UPDATE_COUNTERS_FOR_SPACE(old_pointer_space) - UPDATE_COUNTERS_FOR_SPACE(old_data_space) - UPDATE_COUNTERS_FOR_SPACE(code_space) - UPDATE_COUNTERS_FOR_SPACE(map_space) - UPDATE_COUNTERS_FOR_SPACE(cell_space) - UPDATE_COUNTERS_FOR_SPACE(lo_space) + UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(old_pointer_space) + UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(old_data_space) + UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(code_space) + UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(map_space) + UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(cell_space) + UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(lo_space) #undef UPDATE_COUNTERS_FOR_SPACE +#undef UPDATE_FRAGMENTATION_FOR_SPACE +#undef UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE #if defined(DEBUG) ReportStatisticsAfterGC(); diff --git a/src/v8-counters.h b/src/v8-counters.h index e05a306..e0e05c9 100644 --- a/src/v8-counters.h +++ b/src/v8-counters.h @@ -52,8 +52,8 @@ namespace internal { #define HISTOGRAM_PERCENTAGE_LIST(HP) \ - HP(external_fragmentation_new_space, \ - V8.MemoryExternalFragmentationNewSpace) \ + HP(external_fragmentation_total, \ + V8.MemoryExternalFragmentationTotal) \ HP(external_fragmentation_old_pointer_space, \ V8.MemoryExternalFragmentationOldPointerSpace) \ HP(external_fragmentation_old_data_space, \ -- 2.7.4