[heap] Record UMA for Scavenger sub phases

Reocord UMA counters for the following phases:
- Scavenging roots
- Scavenging object graph in parallel

Bug: chromium:850508
Change-Id: I07210271179ce6801ea6daf3b486b4ce237a3261
Reviewed-on: https://chromium-review.googlesource.com/1199302
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55619}
This commit is contained in:
Michael Lippautz 2018-08-31 21:38:25 +02:00 committed by Commit Bot
parent b45204d607
commit 1d1d4d21e0
5 changed files with 27 additions and 5 deletions

View File

@ -1172,6 +1172,8 @@ class RuntimeCallTimerScope {
HR(gc_finalize_mark, V8.GCFinalizeMC.Mark, 0, 10000, 101) \
HR(gc_finalize_prologue, V8.GCFinalizeMC.Prologue, 0, 10000, 101) \
HR(gc_finalize_sweep, V8.GCFinalizeMC.Sweep, 0, 10000, 101) \
HR(gc_scavenger_scavenge_main, V8.GCScavenger.ScavengeMain, 0, 10000, 101) \
HR(gc_scavenger_scavenge_roots, V8.GCScavenger.ScavengeRoots, 0, 10000, 101) \
HR(scavenge_reason, V8.GCScavengeReason, 0, 21, 22) \
HR(young_generation_handling, V8.GCYoungGenerationHandling, 0, 2, 3) \
/* Asm/Wasm. */ \

View File

@ -1093,7 +1093,7 @@ void GCTracer::AddBackgroundScopeSample(
}
}
void GCTracer::RecordMarkCompactHistograms(HistogramTimer* gc_timer) {
void GCTracer::RecordGCPhasesHistograms(HistogramTimer* gc_timer) {
Counters* counters = heap_->isolate()->counters();
if (gc_timer == counters->gc_finalize()) {
DCHECK_EQ(Scope::FIRST_TOP_MC_SCOPE, Scope::MC_CLEAR);
@ -1112,6 +1112,11 @@ void GCTracer::RecordMarkCompactHistograms(HistogramTimer* gc_timer) {
counters->gc_finalize_sweep()->AddSample(
static_cast<int>(current_.scopes[Scope::MC_SWEEP]));
DCHECK_EQ(Scope::LAST_TOP_MC_SCOPE, Scope::MC_SWEEP);
} else if (gc_timer == counters->gc_scavenger()) {
counters->gc_scavenger_scavenge_main()->AddSample(
static_cast<int>(current_.scopes[Scope::SCAVENGER_SCAVENGE_PARALLEL]));
counters->gc_scavenger_scavenge_roots()->AddSample(
static_cast<int>(current_.scopes[Scope::SCAVENGER_SCAVENGE_ROOTS]));
}
}

View File

@ -321,7 +321,7 @@ class V8_EXPORT_PRIVATE GCTracer {
void AddBackgroundScopeSample(BackgroundScope::ScopeId scope, double duration,
RuntimeCallCounter* runtime_call_counter);
void RecordMarkCompactHistograms(HistogramTimer* gc_timer);
void RecordGCPhasesHistograms(HistogramTimer* gc_timer);
private:
FRIEND_TEST(GCTracer, AverageSpeed);
@ -339,6 +339,7 @@ class V8_EXPORT_PRIVATE GCTracer {
FRIEND_TEST(GCTracerTest, IncrementalMarkingSpeed);
FRIEND_TEST(GCTracerTest, MutatorUtilization);
FRIEND_TEST(GCTracerTest, RecordMarkCompactHistograms);
FRIEND_TEST(GCTracerTest, RecordScavengerHistograms);
struct BackgroundCounter {
double total_duration_ms;

View File

@ -1377,8 +1377,8 @@ bool Heap::CollectGarbage(AllocationSpace space,
next_gc_likely_to_collect_more =
PerformGarbageCollection(collector, gc_callback_flags);
if (collector == MARK_COMPACTOR) {
tracer()->RecordMarkCompactHistograms(gc_type_timer);
if (collector == MARK_COMPACTOR || collector == SCAVENGER) {
tracer()->RecordGCPhasesHistograms(gc_type_timer);
}
}

View File

@ -499,7 +499,7 @@ TEST_F(GCTracerTest, RecordMarkCompactHistograms) {
tracer->current_.scopes[GCTracer::Scope::MC_MARK] = 5;
tracer->current_.scopes[GCTracer::Scope::MC_PROLOGUE] = 6;
tracer->current_.scopes[GCTracer::Scope::MC_SWEEP] = 7;
tracer->RecordMarkCompactHistograms(i_isolate()->counters()->gc_finalize());
tracer->RecordGCPhasesHistograms(i_isolate()->counters()->gc_finalize());
EXPECT_EQ(1, GcHistogram::Get("V8.GCFinalizeMC.Clear")->Total());
EXPECT_EQ(2, GcHistogram::Get("V8.GCFinalizeMC.Epilogue")->Total());
EXPECT_EQ(3, GcHistogram::Get("V8.GCFinalizeMC.Evacuate")->Total());
@ -510,5 +510,19 @@ TEST_F(GCTracerTest, RecordMarkCompactHistograms) {
GcHistogram::CleanUp();
}
TEST_F(GCTracerTest, RecordScavengerHistograms) {
if (FLAG_stress_incremental_marking) return;
isolate()->SetCreateHistogramFunction(&GcHistogram::CreateHistogram);
isolate()->SetAddHistogramSampleFunction(&GcHistogram::AddHistogramSample);
GCTracer* tracer = i_isolate()->heap()->tracer();
tracer->ResetForTesting();
tracer->current_.scopes[GCTracer::Scope::SCAVENGER_SCAVENGE_ROOTS] = 1;
tracer->current_.scopes[GCTracer::Scope::SCAVENGER_SCAVENGE_PARALLEL] = 2;
tracer->RecordGCPhasesHistograms(i_isolate()->counters()->gc_scavenger());
EXPECT_EQ(1, GcHistogram::Get("V8.GCScavenger.ScavengeRoots")->Total());
EXPECT_EQ(2, GcHistogram::Get("V8.GCScavenger.ScavengeMain")->Total());
GcHistogram::CleanUp();
}
} // namespace internal
} // namespace v8