Commit fe76251d authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

[heap] Add GC sum counters

Adds reporting for
- V8.GCMarkCompactor as sum of V8 mark-compact events

Bug: chromium:843903
Change-Id: I5e8a80c8d1a9c5bf696635b54659ac56403f52d5
Reviewed-on: https://chromium-review.googlesource.com/c/1256764
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56750}
parent 05b7a1cb
......@@ -1180,6 +1180,7 @@ class RuntimeCallTimerScope {
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(gc_mark_compactor, V8.GCMarkCompactor, 0, 10000, 101) \
HR(scavenge_reason, V8.GCScavengeReason, 0, 21, 22) \
HR(young_generation_handling, V8.GCYoungGenerationHandling, 0, 2, 3) \
/* Asm/Wasm. */ \
......
......@@ -326,6 +326,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 +338,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();
......@@ -1120,5 +1122,25 @@ void GCTracer::RecordGCPhasesHistograms(HistogramTimer* gc_timer) {
}
}
void GCTracer::RecordGCSumCounters(double atomic_pause_duration) {
// Emit UMA counters.
const double overall_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;
heap_->isolate()->counters()->gc_mark_compactor()->AddSample(
static_cast<int>(overall_duration));
// Emit trace event counters.
TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("v8.gc"),
"V8.GCMarkCompactorSummary", TRACE_EVENT_SCOPE_THREAD,
"duration", overall_duration);
}
} // namespace internal
} // namespace v8
......@@ -338,6 +338,7 @@ class V8_EXPORT_PRIVATE GCTracer {
FRIEND_TEST(GCTracerTest, IncrementalScope);
FRIEND_TEST(GCTracerTest, IncrementalMarkingSpeed);
FRIEND_TEST(GCTracerTest, MutatorUtilization);
FRIEND_TEST(GCTracerTest, RecordGCSumHistograms);
FRIEND_TEST(GCTracerTest, RecordMarkCompactHistograms);
FRIEND_TEST(GCTracerTest, RecordScavengerHistograms);
......@@ -359,6 +360,11 @@ class V8_EXPORT_PRIVATE GCTracer {
void RecordMutatorUtilization(double mark_compactor_end_time,
double mark_compactor_duration);
// Overall time spent in mark compact within a given GC cycle. Exact
// accounting of events within a GC is not necessary which is why the
// recording takes place at the end of the atomic pause.
void RecordGCSumCounters(double atomic_pause_duration);
// Print one detailed trace line in name=value format.
// TODO(ernstm): Move to Heap.
void PrintNVP() const;
......
......@@ -468,7 +468,7 @@ class GcHistogram {
static void CleanUp() { histograms_.clear(); }
int Total() {
int Total() const {
int result = 0;
for (int i : samples_) {
result += i;
......@@ -476,7 +476,7 @@ class GcHistogram {
return result;
}
int Count() { return static_cast<int>(samples_.size()); }
int Count() const { return static_cast<int>(samples_.size()); }
private:
std::vector<int> samples_;
......@@ -524,5 +524,27 @@ TEST_F(GCTracerTest, RecordScavengerHistograms) {
GcHistogram::CleanUp();
}
TEST_F(GCTracerTest, RecordGCSumHistograms) {
if (FLAG_stress_incremental_marking) return;
isolate()->SetCreateHistogramFunction(&GcHistogram::CreateHistogram);
isolate()->SetAddHistogramSampleFunction(&GcHistogram::AddHistogramSample);
GCTracer* tracer = i_isolate()->heap()->tracer();
tracer->ResetForTesting();
tracer->current_
.incremental_marking_scopes[GCTracer::Scope::MC_INCREMENTAL_START]
.duration = 1;
tracer->current_
.incremental_marking_scopes[GCTracer::Scope::MC_INCREMENTAL_SWEEPING]
.duration = 2;
tracer->AddIncrementalMarkingStep(3.0, 1024);
tracer->current_
.incremental_marking_scopes[GCTracer::Scope::MC_INCREMENTAL_FINALIZE]
.duration = 4;
const double atomic_pause_duration = 5.0;
tracer->RecordGCSumCounters(atomic_pause_duration);
EXPECT_EQ(15, GcHistogram::Get("V8.GCMarkCompactor")->Total());
GcHistogram::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