From b4fd9de1f08f0c24ed244026a9b8f53ae359c42d Mon Sep 17 00:00:00 2001 From: "ulan@chromium.org" Date: Tue, 7 Aug 2012 08:19:11 +0000 Subject: [PATCH] Adjust GC tracing: add a flag to ignore scavenger traces and print total GC time in verbose mode. R=mstarzinger@chromium.org Review URL: https://chromiumcodereview.appspot.com/10536147 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12267 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/flag-definitions.h | 2 ++ src/heap.cc | 12 +++++++++--- src/heap.h | 3 +++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/flag-definitions.h b/src/flag-definitions.h index 23d31e580c..714bd8b952 100644 --- a/src/flag-definitions.h +++ b/src/flag-definitions.h @@ -362,6 +362,8 @@ DEFINE_bool(trace_gc, false, DEFINE_bool(trace_gc_nvp, false, "print one detailed trace line in name=value format " "after each garbage collection") +DEFINE_bool(trace_gc_ignore_scavenger, false, + "do not print trace line after scavenger collection") DEFINE_bool(print_cumulative_gc_stat, false, "print cumulative GC statistics in name=value format on exit") DEFINE_bool(trace_gc_verbose, false, diff --git a/src/heap.cc b/src/heap.cc index 9dd91e348c..48cf266826 100644 --- a/src/heap.cc +++ b/src/heap.cc @@ -139,6 +139,7 @@ Heap::Heap() previous_survival_rate_trend_(Heap::STABLE), survival_rate_trend_(Heap::STABLE), max_gc_pause_(0), + total_gc_time_ms_(0), max_alive_after_gc_(0), min_in_mutator_(kMaxInt), alive_after_last_gc_(0), @@ -369,6 +370,7 @@ void Heap::PrintShortHeapStatistics() { lo_space_->SizeOfObjects() / KB, lo_space_->Available() / KB, lo_space_->CommittedMemory() / KB); + PrintPID("Total time spent in GC : %d ms\n", total_gc_time_ms_); } @@ -6188,6 +6190,7 @@ void Heap::TearDown() { PrintF("gc_count=%d ", gc_count_); PrintF("mark_sweep_count=%d ", ms_count_); PrintF("max_gc_pause=%d ", get_max_gc_pause()); + PrintF("total_gc_time=%d ", total_gc_time_ms_); PrintF("min_in_mutator=%d ", get_min_in_mutator()); PrintF("max_alive_after_gc=%" V8_PTR_PREFIX "d ", get_max_alive_after_gc()); @@ -6869,6 +6872,7 @@ GCTracer::~GCTracer() { // Update cumulative GC statistics if required. if (FLAG_print_cumulative_gc_stat) { + heap_->total_gc_time_ms_ += time; heap_->max_gc_pause_ = Max(heap_->max_gc_pause_, time); heap_->max_alive_after_gc_ = Max(heap_->max_alive_after_gc_, heap_->alive_after_last_gc_); @@ -6876,8 +6880,12 @@ GCTracer::~GCTracer() { heap_->min_in_mutator_ = Min(heap_->min_in_mutator_, static_cast(spent_in_mutator_)); } + } else if (FLAG_trace_gc_verbose) { + heap_->total_gc_time_ms_ += time; } + if (collector_ == SCAVENGER && FLAG_trace_gc_ignore_scavenger) return; + PrintPID("%8.0f ms: ", heap_->isolate()->time_millis_since_init()); if (!FLAG_trace_gc_nvp) { @@ -6920,9 +6928,7 @@ GCTracer::~GCTracer() { PrintF(".\n"); } else { PrintF("pause=%d ", time); - PrintF("mutator=%d ", - static_cast(spent_in_mutator_)); - + PrintF("mutator=%d ", static_cast(spent_in_mutator_)); PrintF("gc="); switch (collector_) { case SCAVENGER: diff --git a/src/heap.h b/src/heap.h index 8737010905..72e8d62a8f 100644 --- a/src/heap.h +++ b/src/heap.h @@ -2055,6 +2055,9 @@ class Heap { // Maximum GC pause. int max_gc_pause_; + // Total time spent in GC. + int total_gc_time_ms_; + // Maximum size of objects alive after GC. intptr_t max_alive_after_gc_;