Commit 7a9e3ec9 authored by Ulan Degenbaev's avatar Ulan Degenbaev Committed by Commit Bot

[heap] Record histograms for Mark-Compact phases.

This adds the following histograms recorded corresponding to
V8.GCFinalizeMC phases:
- V8.GCFinalizeMC.Clear
- V8.GCFinalizeMC.Epilogue
- V8.GCFinalizeMC.Evacuate
- V8.GCFinalizeMC.Finish
- V8.GCFinalizeMC.Mark
- V8.GCFinalizeMC.Prologue
- V8.GCFinalizeMC.Sweep

Bug: chromium:850508
Change-Id: I47adc125a9a28436d09e35db68a8e8198cbee2dd
Reviewed-on: https://chromium-review.googlesource.com/1091311
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53614}
parent 310ba80b
......@@ -1128,6 +1128,13 @@ class RuntimeCallTimerScope {
HR(incremental_marking_reason, V8.GCIncrementalMarkingReason, 0, 21, 22) \
HR(incremental_marking_sum, V8.GCIncrementalMarkingSum, 0, 10000, 101) \
HR(mark_compact_reason, V8.GCMarkCompactReason, 0, 21, 22) \
HR(gc_finalize_clear, V8.GCFinalizeMC.Clear, 0, 10000, 101) \
HR(gc_finalize_epilogue, V8.GCFinalizeMC.Epilogue, 0, 10000, 101) \
HR(gc_finalize_evacuate, V8.GCFinalizeMC.Evacuate, 0, 10000, 101) \
HR(gc_finalize_finish, V8.GCFinalizeMC.Finish, 0, 10000, 101) \
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(scavenge_reason, V8.GCScavengeReason, 0, 21, 22) \
HR(young_generation_handling, V8.GCYoungGenerationHandling, 0, 2, 3) \
/* Asm/Wasm. */ \
......
......@@ -292,6 +292,15 @@
F(MC_INCREMENTAL_EXTERNAL_EPILOGUE) \
F(MC_INCREMENTAL_EXTERNAL_PROLOGUE)
#define TOP_MC_SCOPES(F) \
F(MC_CLEAR) \
F(MC_EPILOGUE) \
F(MC_EVACUATE) \
F(MC_FINISH) \
F(MC_MARK) \
F(MC_PROLOGUE) \
F(MC_SWEEP)
#define TRACER_SCOPES(F) \
INCREMENTAL_SCOPES(F) \
F(HEAP_EPILOGUE) \
......@@ -300,7 +309,7 @@
F(HEAP_EXTERNAL_PROLOGUE) \
F(HEAP_EXTERNAL_WEAK_GLOBAL_HANDLES) \
F(HEAP_PROLOGUE) \
F(MC_CLEAR) \
TOP_MC_SCOPES(F) \
F(MC_CLEAR_DEPENDENT_CODE) \
F(MC_CLEAR_MAPS) \
F(MC_CLEAR_SLOTS_BUFFER) \
......@@ -310,8 +319,6 @@
F(MC_CLEAR_WEAK_COLLECTIONS) \
F(MC_CLEAR_WEAK_LISTS) \
F(MC_CLEAR_WEAK_REFERENCES) \
F(MC_EPILOGUE) \
F(MC_EVACUATE) \
F(MC_EVACUATE_CANDIDATES) \
F(MC_EVACUATE_CLEAN_UP) \
F(MC_EVACUATE_COPY) \
......@@ -323,8 +330,6 @@
F(MC_EVACUATE_UPDATE_POINTERS_SLOTS_MAP_SPACE) \
F(MC_EVACUATE_UPDATE_POINTERS_TO_NEW_ROOTS) \
F(MC_EVACUATE_UPDATE_POINTERS_WEAK) \
F(MC_FINISH) \
F(MC_MARK) \
F(MC_MARK_FINISH_INCREMENTAL) \
F(MC_MARK_MAIN) \
F(MC_MARK_ROOTS) \
......@@ -336,8 +341,6 @@
F(MC_MARK_WRAPPER_EPILOGUE) \
F(MC_MARK_WRAPPER_PROLOGUE) \
F(MC_MARK_WRAPPER_TRACING) \
F(MC_PROLOGUE) \
F(MC_SWEEP) \
F(MC_SWEEP_CODE) \
F(MC_SWEEP_MAP) \
F(MC_SWEEP_OLD) \
......
......@@ -1100,5 +1100,27 @@ void GCTracer::AddBackgroundScopeSample(
}
}
void GCTracer::RecordMarkCompactHistograms(HistogramTimer* gc_timer) {
Counters* counters = heap_->isolate()->counters();
if (gc_timer == counters->gc_finalize()) {
DCHECK_EQ(Scope::FIRST_TOP_MC_SCOPE, Scope::MC_CLEAR);
counters->gc_finalize_clear()->AddSample(
static_cast<int>(current_.scopes[Scope::MC_CLEAR]));
counters->gc_finalize_epilogue()->AddSample(
static_cast<int>(current_.scopes[Scope::MC_EPILOGUE]));
counters->gc_finalize_evacuate()->AddSample(
static_cast<int>(current_.scopes[Scope::MC_EVACUATE]));
counters->gc_finalize_finish()->AddSample(
static_cast<int>(current_.scopes[Scope::MC_FINISH]));
counters->gc_finalize_mark()->AddSample(
static_cast<int>(current_.scopes[Scope::MC_MARK]));
counters->gc_finalize_prologue()->AddSample(
static_cast<int>(current_.scopes[Scope::MC_PROLOGUE]));
counters->gc_finalize_sweep()->AddSample(
static_cast<int>(current_.scopes[Scope::MC_SWEEP]));
DCHECK_EQ(Scope::LAST_TOP_MC_SCOPE, Scope::MC_SWEEP);
}
}
} // namespace internal
} // namespace v8
......@@ -79,6 +79,8 @@ class V8_EXPORT_PRIVATE GCTracer {
LAST_GENERAL_BACKGROUND_SCOPE = BACKGROUND_UNMAPPER,
FIRST_MC_BACKGROUND_SCOPE = MC_BACKGROUND_EVACUATE_COPY,
LAST_MC_BACKGROUND_SCOPE = MC_BACKGROUND_SWEEPING,
FIRST_TOP_MC_SCOPE = MC_CLEAR,
LAST_TOP_MC_SCOPE = MC_SWEEP,
FIRST_MINOR_GC_BACKGROUND_SCOPE = MINOR_MC_BACKGROUND_EVACUATE_COPY,
LAST_MINOR_GC_BACKGROUND_SCOPE = SCAVENGER_BACKGROUND_SCAVENGE_PARALLEL
};
......@@ -319,6 +321,8 @@ class V8_EXPORT_PRIVATE GCTracer {
void AddBackgroundScopeSample(BackgroundScope::ScopeId scope, double duration,
RuntimeCallCounter* runtime_call_counter);
void RecordMarkCompactHistograms(HistogramTimer* gc_timer);
private:
FRIEND_TEST(GCTracer, AverageSpeed);
FRIEND_TEST(GCTracerTest, AllocationThroughput);
......@@ -334,6 +338,7 @@ class V8_EXPORT_PRIVATE GCTracer {
FRIEND_TEST(GCTracerTest, IncrementalScope);
FRIEND_TEST(GCTracerTest, IncrementalMarkingSpeed);
FRIEND_TEST(GCTracerTest, MutatorUtilization);
FRIEND_TEST(GCTracerTest, RecordMarkCompactHistograms);
struct BackgroundCounter {
double total_duration_ms;
......
......@@ -1402,6 +1402,9 @@ 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);
}
}
GarbageCollectionEpilogue();
......
......@@ -451,5 +451,65 @@ TEST_F(GCTracerTest, MultithreadedBackgroundScope) {
EXPECT_LE(0, tracer->current_.scopes[GCTracer::Scope::MC_BACKGROUND_MARKING]);
}
class MockHistogram {
public:
static void* CreateHistogram(const char* name, int min, int max,
size_t buckets) {
histograms_[name] = std::unique_ptr<MockHistogram>(new MockHistogram());
return histograms_[name].get();
}
static void AddHistogramSample(void* histogram, int sample) {
static_cast<MockHistogram*>(histogram)->samples_.push_back(sample);
}
static MockHistogram* Get(const char* name) {
return histograms_[name].get();
}
static void CleanUp() { histograms_.clear(); }
int Total() {
int result = 0;
for (int i : samples_) {
result += i;
}
return result;
}
int Count() { return static_cast<int>(samples_.size()); }
private:
std::vector<int> samples_;
static std::map<std::string, std::unique_ptr<MockHistogram>> histograms_;
};
std::map<std::string, std::unique_ptr<MockHistogram>>
MockHistogram::histograms_ =
std::map<std::string, std::unique_ptr<MockHistogram>>();
TEST_F(GCTracerTest, RecordMarkCompactHistograms) {
isolate()->SetCreateHistogramFunction(&MockHistogram::CreateHistogram);
isolate()->SetAddHistogramSampleFunction(&MockHistogram::AddHistogramSample);
GCTracer* tracer = i_isolate()->heap()->tracer();
tracer->ResetForTesting();
tracer->current_.scopes[GCTracer::Scope::MC_CLEAR] = 1;
tracer->current_.scopes[GCTracer::Scope::MC_EPILOGUE] = 2;
tracer->current_.scopes[GCTracer::Scope::MC_EVACUATE] = 3;
tracer->current_.scopes[GCTracer::Scope::MC_FINISH] = 4;
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());
EXPECT_EQ(1, MockHistogram::Get("V8.GCFinalizeMC.Clear")->Total());
EXPECT_EQ(2, MockHistogram::Get("V8.GCFinalizeMC.Epilogue")->Total());
EXPECT_EQ(3, MockHistogram::Get("V8.GCFinalizeMC.Evacuate")->Total());
EXPECT_EQ(4, MockHistogram::Get("V8.GCFinalizeMC.Finish")->Total());
EXPECT_EQ(5, MockHistogram::Get("V8.GCFinalizeMC.Mark")->Total());
EXPECT_EQ(6, MockHistogram::Get("V8.GCFinalizeMC.Prologue")->Total());
EXPECT_EQ(7, MockHistogram::Get("V8.GCFinalizeMC.Sweep")->Total());
MockHistogram::CleanUp();
}
} // namespace internal
} // namespace v8
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment