diff options
Diffstat (limited to 'deps/v8/src/heap/gc-tracer.cc')
-rw-r--r-- | deps/v8/src/heap/gc-tracer.cc | 94 |
1 files changed, 78 insertions, 16 deletions
diff --git a/deps/v8/src/heap/gc-tracer.cc b/deps/v8/src/heap/gc-tracer.cc index 7d33c68ad1..c3f7ff3029 100644 --- a/deps/v8/src/heap/gc-tracer.cc +++ b/deps/v8/src/heap/gc-tracer.cc @@ -7,8 +7,10 @@ #include <cstdarg> #include "src/base/atomic-utils.h" -#include "src/counters.h" +#include "src/counters-inl.h" #include "src/heap/heap-inl.h" +#include "src/heap/incremental-marking.h" +#include "src/heap/spaces.h" #include "src/isolate.h" namespace v8 { @@ -196,7 +198,7 @@ void GCTracer::ResetForTesting() { average_mark_compact_duration_ = 0; current_mark_compact_mutator_utilization_ = 1.0; previous_mark_compact_end_time_ = 0; - base::LockGuard<base::Mutex> guard(&background_counter_mutex_); + base::MutexGuard guard(&background_counter_mutex_); for (int i = 0; i < BackgroundScope::NUMBER_OF_SCOPES; i++) { background_counter_[i].total_duration_ms = 0; background_counter_[i].runtime_call_counter.Reset(); @@ -326,6 +328,7 @@ void GCTracer::Stop(GarbageCollector collector) { current_.incremental_marking_duration); recorded_incremental_mark_compacts_.Push( MakeBytesAndDuration(current_.start_object_size, duration)); + RecordGCSumCounters(duration); ResetIncrementalMarkingCounters(); combined_mark_compact_speed_cache_ = 0.0; FetchBackgroundMarkCompactCounters(); @@ -337,6 +340,7 @@ void GCTracer::Stop(GarbageCollector collector) { current_.end_time, duration + current_.incremental_marking_duration); recorded_mark_compacts_.Push( MakeBytesAndDuration(current_.start_object_size, duration)); + RecordGCSumCounters(duration); ResetIncrementalMarkingCounters(); combined_mark_compact_speed_cache_ = 0.0; FetchBackgroundMarkCompactCounters(); @@ -654,6 +658,7 @@ void GCTracer::PrintNVP() const { "gc=%s " "reduce_memory=%d " "heap.prologue=%.2f " + "heap.embedder_tracing_epilogue=%.2f " "heap.epilogue=%.2f " "heap.epilogue.reduce_new_space=%.2f " "heap.external.prologue=%.1f " @@ -693,9 +698,8 @@ void GCTracer::PrintNVP() const { "mark.weak_closure.weak_handles=%.1f " "mark.weak_closure.weak_roots=%.1f " "mark.weak_closure.harmony=%.1f " - "mark.wrapper_prologue=%.1f " - "mark.wrapper_epilogue=%.1f " - "mark.wrapper_tracing=%.1f " + "mark.embedder_prologue=%.1f " + "mark.embedder_tracing=%.1f " "prologue=%.1f " "sweep=%.1f " "sweep.code=%.1f " @@ -706,9 +710,11 @@ void GCTracer::PrintNVP() const { "incremental.finalize.body=%.1f " "incremental.finalize.external.prologue=%.1f " "incremental.finalize.external.epilogue=%.1f " + "incremental.layout_change=%.1f " + "incremental.start=%.1f " "incremental.sweeping=%.1f " - "incremental.wrapper_prologue=%.1f " - "incremental.wrapper_tracing=%.1f " + "incremental.embedder_prologue=%.1f " + "incremental.embedder_tracing=%.1f " "incremental_wrapper_tracing_longest_step=%.1f " "incremental_finalize_longest_step=%.1f " "incremental_finalize_steps_count=%d " @@ -750,6 +756,7 @@ void GCTracer::PrintNVP() const { "compaction_speed=%.f\n", duration, spent_in_mutator, current_.TypeName(true), current_.reduce_memory, current_.scopes[Scope::HEAP_PROLOGUE], + current_.scopes[Scope::HEAP_EMBEDDER_TRACING_EPILOGUE], current_.scopes[Scope::HEAP_EPILOGUE], current_.scopes[Scope::HEAP_EPILOGUE_REDUCE_NEW_SPACE], current_.scopes[Scope::HEAP_EXTERNAL_PROLOGUE], @@ -788,9 +795,8 @@ void GCTracer::PrintNVP() const { current_.scopes[Scope::MC_MARK_WEAK_CLOSURE_WEAK_HANDLES], current_.scopes[Scope::MC_MARK_WEAK_CLOSURE_WEAK_ROOTS], current_.scopes[Scope::MC_MARK_WEAK_CLOSURE_HARMONY], - current_.scopes[Scope::MC_MARK_WRAPPER_PROLOGUE], - current_.scopes[Scope::MC_MARK_WRAPPER_EPILOGUE], - current_.scopes[Scope::MC_MARK_WRAPPER_TRACING], + current_.scopes[Scope::MC_MARK_EMBEDDER_PROLOGUE], + current_.scopes[Scope::MC_MARK_EMBEDDER_TRACING], current_.scopes[Scope::MC_PROLOGUE], current_.scopes[Scope::MC_SWEEP], current_.scopes[Scope::MC_SWEEP_CODE], current_.scopes[Scope::MC_SWEEP_MAP], @@ -800,11 +806,14 @@ void GCTracer::PrintNVP() const { current_.scopes[Scope::MC_INCREMENTAL_FINALIZE_BODY], current_.scopes[Scope::MC_INCREMENTAL_EXTERNAL_PROLOGUE], current_.scopes[Scope::MC_INCREMENTAL_EXTERNAL_EPILOGUE], + current_.scopes[Scope::MC_INCREMENTAL_LAYOUT_CHANGE], + current_.scopes[Scope::MC_INCREMENTAL_START], current_.scopes[Scope::MC_INCREMENTAL_SWEEPING], - current_.scopes[Scope::MC_INCREMENTAL_WRAPPER_PROLOGUE], - current_.scopes[Scope::MC_INCREMENTAL_WRAPPER_TRACING], + current_.scopes[Scope::MC_INCREMENTAL_EMBEDDER_PROLOGUE], + current_.scopes[Scope::MC_INCREMENTAL_EMBEDDER_TRACING], current_ - .incremental_marking_scopes[Scope::MC_INCREMENTAL_WRAPPER_TRACING] + .incremental_marking_scopes + [Scope::MC_INCREMENTAL_EMBEDDER_TRACING] .longest_step, current_ .incremental_marking_scopes[Scope::MC_INCREMENTAL_FINALIZE_BODY] @@ -1060,7 +1069,7 @@ void GCTracer::FetchBackgroundCounters(int first_global_scope, int last_background_scope) { DCHECK_EQ(last_global_scope - first_global_scope, last_background_scope - first_background_scope); - base::LockGuard<base::Mutex> guard(&background_counter_mutex_); + base::MutexGuard guard(&background_counter_mutex_); int background_mc_scopes = last_background_scope - first_background_scope + 1; for (int i = 0; i < background_mc_scopes; i++) { current_.scopes[first_global_scope + i] += @@ -1085,7 +1094,7 @@ void GCTracer::FetchBackgroundCounters(int first_global_scope, void GCTracer::AddBackgroundScopeSample( BackgroundScope::ScopeId scope, double duration, RuntimeCallCounter* runtime_call_counter) { - base::LockGuard<base::Mutex> guard(&background_counter_mutex_); + base::MutexGuard guard(&background_counter_mutex_); BackgroundCounter& counter = background_counter_[scope]; counter.total_duration_ms += duration; if (runtime_call_counter) { @@ -1093,7 +1102,7 @@ void GCTracer::AddBackgroundScopeSample( } } -void GCTracer::RecordGCPhasesHistograms(HistogramTimer* gc_timer) { +void GCTracer::RecordGCPhasesHistograms(TimedHistogram* gc_timer) { Counters* counters = heap_->isolate()->counters(); if (gc_timer == counters->gc_finalize()) { DCHECK_EQ(Scope::FIRST_TOP_MC_SCOPE, Scope::MC_CLEAR); @@ -1120,5 +1129,58 @@ void GCTracer::RecordGCPhasesHistograms(HistogramTimer* gc_timer) { } } +void GCTracer::RecordGCSumCounters(double atomic_pause_duration) { + base::MutexGuard guard(&background_counter_mutex_); + + const double overall_duration = + current_.incremental_marking_scopes[Scope::MC_INCREMENTAL_LAYOUT_CHANGE] + .duration + + current_.incremental_marking_scopes[Scope::MC_INCREMENTAL_START] + .duration + + current_.incremental_marking_scopes[Scope::MC_INCREMENTAL_SWEEPING] + .duration + + incremental_marking_duration_ + + current_.incremental_marking_scopes[Scope::MC_INCREMENTAL_FINALIZE] + .duration + + atomic_pause_duration; + const double background_duration = + background_counter_[BackgroundScope::MC_BACKGROUND_EVACUATE_COPY] + .total_duration_ms + + background_counter_ + [BackgroundScope::MC_BACKGROUND_EVACUATE_UPDATE_POINTERS] + .total_duration_ms + + background_counter_[BackgroundScope::MC_BACKGROUND_MARKING] + .total_duration_ms + + background_counter_[BackgroundScope::MC_BACKGROUND_SWEEPING] + .total_duration_ms; + + const double marking_duration = + current_.incremental_marking_scopes[Scope::MC_INCREMENTAL_LAYOUT_CHANGE] + .duration + + current_.incremental_marking_scopes[Scope::MC_INCREMENTAL_START] + .duration + + incremental_marking_duration_ + + current_.incremental_marking_scopes[Scope::MC_INCREMENTAL_FINALIZE] + .duration + + current_.scopes[Scope::MC_MARK]; + const double marking_background_duration = + background_counter_[BackgroundScope::MC_BACKGROUND_MARKING] + .total_duration_ms; + + // UMA. + heap_->isolate()->counters()->gc_mark_compactor()->AddSample( + static_cast<int>(overall_duration)); + + // Emit trace event counters. + TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("v8.gc"), + "V8.GCMarkCompactorSummary", TRACE_EVENT_SCOPE_THREAD, + "duration", overall_duration, "background_duration", + background_duration); + TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("v8.gc"), + "V8.GCMarkCompactorMarkingSummary", + TRACE_EVENT_SCOPE_THREAD, "duration", marking_duration, + "background_duration", marking_background_duration); +} + } // namespace internal } // namespace v8 |