Commit f31fb295 authored by Nikolaos Papaspyrou's avatar Nikolaos Papaspyrou Committed by V8 LUCI CQ

heap: Introduce v8:gc:cycle:young UMA events

Report young generation GC statistics to the Recorder API.
These will be used by Blink to populate UMA histograms.
Existing UMA reporting in V8 remains as is for now and will be removed
in a followup.

This CL goes together with:
https://chromium-review.googlesource.com/c/chromium/src/+/3247446

Change-Id: I1fed070d4a3996c4d0d8942b455d722afafcc4ab
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3247635
Commit-Queue: Nikolaos Papaspyrou <nikolaos@chromium.org>
Reviewed-by: 's avatarOmer Katz <omerkatz@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77731}
parent 74d9a764
...@@ -93,7 +93,7 @@ GCTracer::Scope::~Scope() { ...@@ -93,7 +93,7 @@ GCTracer::Scope::~Scope() {
tracer_->AddScopeSample(scope_, duration_ms); tracer_->AddScopeSample(scope_, duration_ms);
if (scope_ == ScopeId::MC_INCREMENTAL || if (scope_ == ScopeId::MC_INCREMENTAL ||
scope_ == ScopeId::MC_INCREMENTAL_START || scope_ == ScopeId::MC_INCREMENTAL_START ||
scope_ == MC_INCREMENTAL_FINALIZE) { scope_ == ScopeId::MC_INCREMENTAL_FINALIZE) {
auto* long_task_stats = auto* long_task_stats =
tracer_->heap_->isolate()->GetCurrentLongTaskStats(); tracer_->heap_->isolate()->GetCurrentLongTaskStats();
long_task_stats->gc_full_incremental_wall_clock_duration_us += long_task_stats->gc_full_incremental_wall_clock_duration_us +=
...@@ -411,10 +411,11 @@ void GCTracer::Stop(GarbageCollector collector) { ...@@ -411,10 +411,11 @@ void GCTracer::Stop(GarbageCollector collector) {
heap_->UpdateTotalGCTime(duration); heap_->UpdateTotalGCTime(duration);
if ((current_.type == Event::SCAVENGER || if (current_.type == Event::SCAVENGER ||
current_.type == Event::MINOR_MARK_COMPACTOR) && current_.type == Event::MINOR_MARK_COMPACTOR) {
FLAG_trace_gc_ignore_scavenger) ReportYoungCycleToRecorder();
return; if (FLAG_trace_gc_ignore_scavenger) return;
}
if (FLAG_trace_gc_nvp) { if (FLAG_trace_gc_nvp) {
PrintNVP(); PrintNVP();
...@@ -1444,5 +1445,39 @@ void GCTracer::ReportIncrementalMarkingStepToRecorder() { ...@@ -1444,5 +1445,39 @@ void GCTracer::ReportIncrementalMarkingStepToRecorder() {
} }
} }
void GCTracer::ReportYoungCycleToRecorder() {
const std::shared_ptr<metrics::Recorder>& recorder =
heap_->isolate()->metrics_recorder();
DCHECK_NOT_NULL(recorder);
if (!recorder->HasEmbedderRecorder()) return;
v8::metrics::GarbageCollectionYoungCycle event;
// Total:
const double total_wall_clock_duration_in_us =
(current_.scopes[Scope::SCAVENGER] +
current_.scopes[Scope::SCAVENGER_BACKGROUND_SCAVENGE_PARALLEL]) *
base::Time::kMicrosecondsPerMillisecond;
event.total_wall_clock_duration_in_us =
static_cast<int64_t>(total_wall_clock_duration_in_us);
// MainThread:
const double main_thread_wall_clock_duration_in_us =
current_.scopes[Scope::SCAVENGER] *
base::Time::kMicrosecondsPerMillisecond;
event.main_thread_wall_clock_duration_in_us =
static_cast<int64_t>(main_thread_wall_clock_duration_in_us);
// Collection Rate:
event.collection_rate_in_percent =
static_cast<double>(current_.survived_young_object_size) /
current_.young_object_size;
// Efficiency:
auto freed_bytes =
current_.young_object_size - current_.survived_young_object_size;
event.efficiency_in_bytes_per_us =
freed_bytes / total_wall_clock_duration_in_us;
event.main_thread_efficiency_in_bytes_per_us =
freed_bytes / main_thread_wall_clock_duration_in_us;
recorder->AddMainThreadEvent(event, GetContextId(heap_->isolate()));
}
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
...@@ -75,8 +75,8 @@ class V8_EXPORT_PRIVATE GCTracer { ...@@ -75,8 +75,8 @@ class V8_EXPORT_PRIVATE GCTracer {
steps = 0; steps = 0;
} }
double duration; double duration; // in ms
double longest_step; double longest_step; // in ms
int steps; int steps;
}; };
...@@ -183,10 +183,11 @@ class V8_EXPORT_PRIVATE GCTracer { ...@@ -183,10 +183,11 @@ class V8_EXPORT_PRIVATE GCTracer {
// Bytes marked incrementally for INCREMENTAL_MARK_COMPACTOR // Bytes marked incrementally for INCREMENTAL_MARK_COMPACTOR
size_t incremental_marking_bytes; size_t incremental_marking_bytes;
// Duration of incremental marking steps for INCREMENTAL_MARK_COMPACTOR. // Duration (in ms) of incremental marking steps for
// INCREMENTAL_MARK_COMPACTOR.
double incremental_marking_duration; double incremental_marking_duration;
// Amounts of time spent in different scopes during GC. // Amounts of time (in ms) spent in different scopes during GC.
double scopes[Scope::NUMBER_OF_SCOPES]; double scopes[Scope::NUMBER_OF_SCOPES];
// Holds details for incremental marking scopes. // Holds details for incremental marking scopes.
...@@ -421,6 +422,7 @@ class V8_EXPORT_PRIVATE GCTracer { ...@@ -421,6 +422,7 @@ class V8_EXPORT_PRIVATE GCTracer {
void ReportFullCycleToRecorder(); void ReportFullCycleToRecorder();
void ReportIncrementalMarkingStepToRecorder(); void ReportIncrementalMarkingStepToRecorder();
void ReportYoungCycleToRecorder();
// Pointer to the heap that owns this tracer. // Pointer to the heap that owns this tracer.
Heap* heap_; Heap* heap_;
...@@ -436,8 +438,8 @@ class V8_EXPORT_PRIVATE GCTracer { ...@@ -436,8 +438,8 @@ class V8_EXPORT_PRIVATE GCTracer {
// the last mark compact GC. // the last mark compact GC.
size_t incremental_marking_bytes_; size_t incremental_marking_bytes_;
// Duration of incremental marking steps since the end of the last mark- // Duration (in ms) of incremental marking steps since the end of the last
// compact event. // mark-compact event.
double incremental_marking_duration_; double incremental_marking_duration_;
double incremental_marking_start_time_; double incremental_marking_start_time_;
...@@ -460,7 +462,7 @@ class V8_EXPORT_PRIVATE GCTracer { ...@@ -460,7 +462,7 @@ class V8_EXPORT_PRIVATE GCTracer {
size_t old_generation_allocation_counter_bytes_; size_t old_generation_allocation_counter_bytes_;
size_t embedder_allocation_counter_bytes_; size_t embedder_allocation_counter_bytes_;
// Accumulated duration and allocated bytes since the last GC. // Accumulated duration (in ms) and allocated bytes since the last GC.
double allocation_duration_since_gc_; double allocation_duration_since_gc_;
size_t new_space_allocation_in_bytes_since_gc_; size_t new_space_allocation_in_bytes_since_gc_;
size_t old_generation_allocation_in_bytes_since_gc_; size_t old_generation_allocation_in_bytes_since_gc_;
......
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