Expose more detailed memory statistics
authormstarzinger@chromium.org <mstarzinger@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 26 Jun 2012 11:46:16 +0000 (11:46 +0000)
committermstarzinger@chromium.org <mstarzinger@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 26 Jun 2012 11:46:16 +0000 (11:46 +0000)
Expose allocated and used byte counters for the different spaces. The goal is
to monitor those values both on page cycles and via UMA

BUG=v8:2201
TEST=none

Review URL: https://chromiumcodereview.appspot.com/10657022
Patch from Jochen Eisinger <jochen@chromium.org>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11931 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/heap.cc
src/v8-counters.h

index d8395e3..7d655b4 100644 (file)
@@ -444,6 +444,56 @@ void Heap::GarbageCollectionEpilogue() {
       symbol_table()->Capacity());
   isolate_->counters()->number_of_symbols()->Set(
       symbol_table()->NumberOfElements());
+
+  isolate_->counters()->new_space_bytes_available()->Set(
+      static_cast<int>(new_space()->Available()));
+  isolate_->counters()->new_space_bytes_committed()->Set(
+      static_cast<int>(new_space()->CommittedMemory()));
+  isolate_->counters()->new_space_bytes_used()->Set(
+      static_cast<int>(new_space()->SizeOfObjects()));
+
+  isolate_->counters()->old_pointer_space_bytes_available()->Set(
+      static_cast<int>(old_pointer_space()->Available()));
+  isolate_->counters()->old_pointer_space_bytes_committed()->Set(
+      static_cast<int>(old_pointer_space()->CommittedMemory()));
+  isolate_->counters()->old_pointer_space_bytes_used()->Set(
+      static_cast<int>(old_pointer_space()->SizeOfObjects()));
+
+  isolate_->counters()->old_data_space_bytes_available()->Set(
+      static_cast<int>(old_data_space()->Available()));
+  isolate_->counters()->old_data_space_bytes_committed()->Set(
+      static_cast<int>(old_data_space()->CommittedMemory()));
+  isolate_->counters()->old_data_space_bytes_used()->Set(
+      static_cast<int>(old_data_space()->SizeOfObjects()));
+
+  isolate_->counters()->code_space_bytes_available()->Set(
+      static_cast<int>(code_space()->Available()));
+  isolate_->counters()->code_space_bytes_committed()->Set(
+      static_cast<int>(code_space()->CommittedMemory()));
+  isolate_->counters()->code_space_bytes_used()->Set(
+      static_cast<int>(code_space()->SizeOfObjects()));
+
+  isolate_->counters()->map_space_bytes_available()->Set(
+      static_cast<int>(map_space()->Available()));
+  isolate_->counters()->map_space_bytes_committed()->Set(
+      static_cast<int>(map_space()->CommittedMemory()));
+  isolate_->counters()->map_space_bytes_used()->Set(
+      static_cast<int>(map_space()->SizeOfObjects()));
+
+  isolate_->counters()->cell_space_bytes_available()->Set(
+      static_cast<int>(cell_space()->Available()));
+  isolate_->counters()->cell_space_bytes_committed()->Set(
+      static_cast<int>(cell_space()->CommittedMemory()));
+  isolate_->counters()->cell_space_bytes_used()->Set(
+      static_cast<int>(cell_space()->SizeOfObjects()));
+
+  isolate_->counters()->lo_space_bytes_available()->Set(
+      static_cast<int>(lo_space()->Available()));
+  isolate_->counters()->lo_space_bytes_committed()->Set(
+      static_cast<int>(lo_space()->CommittedMemory()));
+  isolate_->counters()->lo_space_bytes_used()->Set(
+      static_cast<int>(lo_space()->SizeOfObjects()));
+
 #if defined(DEBUG)
   ReportStatisticsAfterGC();
 #endif  // DEBUG
index f36b0ed..dc55042 100644 (file)
@@ -246,7 +246,30 @@ namespace internal {
   SC(smi_checks_removed, V8.SmiChecksRemoved)                         \
   SC(map_checks_removed, V8.MapChecksRemoved)                         \
   SC(quote_json_char_count, V8.QuoteJsonCharacterCount)               \
-  SC(quote_json_char_recount, V8.QuoteJsonCharacterReCount)
+  SC(quote_json_char_recount, V8.QuoteJsonCharacterReCount)           \
+  SC(new_space_bytes_available, V8.MemoryNewSpaceBytesAvailable)      \
+  SC(new_space_bytes_committed, V8.MemoryNewSpaceBytesCommitted)      \
+  SC(new_space_bytes_used, V8.MemoryNewSpaceBytesUsed)                \
+  SC(old_pointer_space_bytes_available,                               \
+     V8.MemoryOldPointerSpaceBytesAvailable)                          \
+  SC(old_pointer_space_bytes_committed,                               \
+     V8.MemoryOldPointerSpaceBytesCommitted)                          \
+  SC(old_pointer_space_bytes_used, V8.MemoryOldPointerSpaceBytesUsed) \
+  SC(old_data_space_bytes_available, V8.MemoryOldDataSpaceBytesAvailable) \
+  SC(old_data_space_bytes_committed, V8.MemoryOldDataSpaceBytesCommitted) \
+  SC(old_data_space_bytes_used, V8.MemoryOldDataSpaceBytesUsed)       \
+  SC(code_space_bytes_available, V8.MemoryCodeSpaceBytesAvailable)    \
+  SC(code_space_bytes_committed, V8.MemoryCodeSpaceBytesCommitted)    \
+  SC(code_space_bytes_used, V8.MemoryCodeSpaceBytesUsed)              \
+  SC(map_space_bytes_available, V8.MemoryMapSpaceBytesAvailable)      \
+  SC(map_space_bytes_committed, V8.MemoryMapSpaceBytesCommitted)      \
+  SC(map_space_bytes_used, V8.MemoryMapSpaceBytesUsed)                \
+  SC(cell_space_bytes_available, V8.MemoryCellSpaceBytesAvailable)    \
+  SC(cell_space_bytes_committed, V8.MemoryCellSpaceBytesCommitted)    \
+  SC(cell_space_bytes_used, V8.MemoryCellSpaceBytesUsed)              \
+  SC(lo_space_bytes_available, V8.MemoryLoSpaceBytesAvailable)        \
+  SC(lo_space_bytes_committed, V8.MemoryLoSpaceBytesCommitted)        \
+  SC(lo_space_bytes_used, V8.MemoryLoSpaceBytesUsed)
 
 
 // This file contains all the v8 counters that are in use.