From 2d0d210eca8a879a303418dcc4eb05efffe26e72 Mon Sep 17 00:00:00 2001 From: "mstarzinger@chromium.org" Date: Mon, 14 Oct 2013 14:00:28 +0000 Subject: [PATCH] Add histograms to track fraction of heap spaces and percentage of generated crankshaft code. BUG=None R=mstarzinger@chromium.org Review URL: https://codereview.chromium.org/27023003 Patch from Ross McIlroy . git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17198 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/codegen.cc | 2 ++ src/heap.cc | 28 ++++++++++++++++++++++++++++ src/heap.h | 12 ++++++++++++ src/v8-counters.h | 17 +++++++++++++++++ 4 files changed, 59 insertions(+) diff --git a/src/codegen.cc b/src/codegen.cc index d33c7f06bd..b15324c8cf 100644 --- a/src/codegen.cc +++ b/src/codegen.cc @@ -116,6 +116,8 @@ Handle CodeGenerator::MakeCodeEpilogue(MacroAssembler* masm, false, is_crankshafted); isolate->counters()->total_compiled_code_size()->Increment( code->instruction_size()); + isolate->heap()->IncrementCodeGeneratedBytes(is_crankshafted, + code->instruction_size()); code->set_prologue_offset(info->prologue_offset()); return code; } diff --git a/src/heap.cc b/src/heap.cc index 256ee8bb97..76f34b263a 100644 --- a/src/heap.cc +++ b/src/heap.cc @@ -141,6 +141,8 @@ Heap::Heap() mark_sweeps_since_idle_round_started_(0), gc_count_at_last_idle_gc_(0), scavenges_since_last_idle_round_(kIdleScavengeThreshold), + full_codegen_bytes_generated_(0), + crankshaft_codegen_bytes_generated_(0), gcs_since_last_deopt_(0), #ifdef VERIFY_HEAP no_weak_object_verification_scope_depth_(0), @@ -508,10 +510,31 @@ void Heap::GarbageCollectionEpilogue() { isolate_->counters()->number_of_symbols()->Set( string_table()->NumberOfElements()); + if (full_codegen_bytes_generated_ + crankshaft_codegen_bytes_generated_ > 0) { + isolate_->counters()->codegen_fraction_crankshaft()->AddSample( + static_cast((crankshaft_codegen_bytes_generated_ * 100.0) / + (crankshaft_codegen_bytes_generated_ + + full_codegen_bytes_generated_))); + } + if (CommittedMemory() > 0) { isolate_->counters()->external_fragmentation_total()->AddSample( static_cast(100 - (SizeOfObjects() * 100.0) / CommittedMemory())); + isolate_->counters()->heap_fraction_new_space()-> + AddSample(static_cast( + (new_space()->CommittedMemory() * 100.0) / CommittedMemory())); + isolate_->counters()->heap_fraction_old_pointer_space()->AddSample( + static_cast( + (old_pointer_space()->CommittedMemory() * 100.0) / + CommittedMemory())); + isolate_->counters()->heap_fraction_old_data_space()->AddSample( + static_cast( + (old_data_space()->CommittedMemory() * 100.0) / + CommittedMemory())); + isolate_->counters()->heap_fraction_code_space()-> + AddSample(static_cast( + (code_space()->CommittedMemory() * 100.0) / CommittedMemory())); isolate_->counters()->heap_fraction_map_space()->AddSample( static_cast( (map_space()->CommittedMemory() * 100.0) / CommittedMemory())); @@ -522,6 +545,9 @@ void Heap::GarbageCollectionEpilogue() { AddSample(static_cast( (property_cell_space()->CommittedMemory() * 100.0) / CommittedMemory())); + isolate_->counters()->heap_fraction_lo_space()-> + AddSample(static_cast( + (lo_space()->CommittedMemory() * 100.0) / CommittedMemory())); isolate_->counters()->heap_sample_total_committed()->AddSample( static_cast(CommittedMemory() / KB)); @@ -535,6 +561,8 @@ void Heap::GarbageCollectionEpilogue() { heap_sample_property_cell_space_committed()-> AddSample(static_cast( property_cell_space()->CommittedMemory() / KB)); + isolate_->counters()->heap_sample_code_space_committed()->AddSample( + static_cast(code_space()->CommittedMemory() / KB)); } #define UPDATE_COUNTERS_FOR_SPACE(space) \ diff --git a/src/heap.h b/src/heap.h index 52d932f54b..2344488bd0 100644 --- a/src/heap.h +++ b/src/heap.h @@ -1676,6 +1676,14 @@ class Heap { total_regexp_code_generated_ += size; } + void IncrementCodeGeneratedBytes(bool is_crankshafted, int size) { + if (is_crankshafted) { + crankshaft_codegen_bytes_generated_ += size; + } else { + full_codegen_bytes_generated_ += size; + } + } + // Returns maximum GC pause. double get_max_gc_pause() { return max_gc_pause_; } @@ -2371,6 +2379,10 @@ class Heap { unsigned int gc_count_at_last_idle_gc_; int scavenges_since_last_idle_round_; + // These two counters are monotomically increasing and never reset. + size_t full_codegen_bytes_generated_; + size_t crankshaft_codegen_bytes_generated_; + // If the --deopt_every_n_garbage_collections flag is set to a positive value, // this variable holds the number of garbage collections since the last // deoptimization triggered by garbage collection. diff --git a/src/v8-counters.h b/src/v8-counters.h index c1541b097f..04f57f7393 100644 --- a/src/v8-counters.h +++ b/src/v8-counters.h @@ -51,6 +51,7 @@ namespace internal { HT(compile_lazy, V8.CompileLazy) #define HISTOGRAM_PERCENTAGE_LIST(HP) \ + /* Heap fragmentation. */ \ HP(external_fragmentation_total, \ V8.MemoryExternalFragmentationTotal) \ HP(external_fragmentation_old_pointer_space, \ @@ -67,12 +68,26 @@ namespace internal { V8.MemoryExternalFragmentationPropertyCellSpace) \ HP(external_fragmentation_lo_space, \ V8.MemoryExternalFragmentationLoSpace) \ + /* Percentages of heap committed to each space. */ \ + HP(heap_fraction_new_space, \ + V8.MemoryHeapFractionNewSpace) \ + HP(heap_fraction_old_pointer_space, \ + V8.MemoryHeapFractionOldPointerSpace) \ + HP(heap_fraction_old_data_space, \ + V8.MemoryHeapFractionOldDataSpace) \ + HP(heap_fraction_code_space, \ + V8.MemoryHeapFractionCodeSpace) \ HP(heap_fraction_map_space, \ V8.MemoryHeapFractionMapSpace) \ HP(heap_fraction_cell_space, \ V8.MemoryHeapFractionCellSpace) \ HP(heap_fraction_property_cell_space, \ V8.MemoryHeapFractionPropertyCellSpace) \ + HP(heap_fraction_lo_space, \ + V8.MemoryHeapFractionLoSpace) \ + /* Percentage of crankshafted codegen. */ \ + HP(codegen_fraction_crankshaft, \ + V8.CodegenFractionCrankshaft) \ #define HISTOGRAM_MEMORY_LIST(HM) \ @@ -84,6 +99,8 @@ namespace internal { V8.MemoryHeapSampleCellSpaceCommitted) \ HM(heap_sample_property_cell_space_committed, \ V8.MemoryHeapSamplePropertyCellSpaceCommitted) \ + HM(heap_sample_code_space_committed, \ + V8.MemoryHeapSampleCodeSpaceCommitted) \ // WARNING: STATS_COUNTER_LIST_* is a very large macro that is causing MSVC