From b6319aa855b86a0095d6c0c27630ffeb5d4676ba Mon Sep 17 00:00:00 2001 From: Omer Katz Date: Thu, 2 Sep 2021 15:49:28 +0000 Subject: [PATCH] heap: Fix atomic pause UMA histograms The new naming scheme for GC UMA histogram used the Event prefix for all atomic pause histograms. This was explained as: there should only be a single atomic pause per cycle, so Event and Cycle prefixes are equivalent in this case. The underlying implementation assumed that there is indeed a single atomic pause event. This assumption holds for V8 (V8.GC_MARK_COMPACTOR) but not for Oilpan. Oilpan has a top level event for each phase of the atomic pause (CppGC.AtomicMark, CppGC.AtomicSweep, etc.) and the overall atomic pause is defined as the sum of these events. When reporting atomic pause histograms using the Event prefix, we reported each event separately (similar to incremental evnets) which messed the actual histogram. This CL replaces the Event prefixed Oilpan atomic pause histogram with Cycle prefixed histograms. The histograms are kept aligned with their gc metric counterparts. Bug: 1056170 Change-Id: I7096334abbcc460716f89b77f08cf550d82f26ec Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3137717 Commit-Queue: Omer Katz Reviewed-by: Michael Lippautz Cr-Commit-Position: refs/heads/main@{#917680} --- .../renderer/bindings/core/v8/v8_metrics.cc | 30 +++----- .../histograms/metadata/v8/histograms.xml | 75 +++++++++++++++++++ 2 files changed, 87 insertions(+), 18 deletions(-) diff --git a/third_party/blink/renderer/bindings/core/v8/v8_metrics.cc b/third_party/blink/renderer/bindings/core/v8/v8_metrics.cc index 69711164e4fb2e..3a1cf177ff8e3a 100644 --- a/third_party/blink/renderer/bindings/core/v8/v8_metrics.cc +++ b/third_party/blink/renderer/bindings/core/v8/v8_metrics.cc @@ -86,11 +86,6 @@ void V8MetricsRecorder::AddMainThreadEvent( namespace { #if BUILDFLAG(USE_V8_OILPAN) -void ReportAtomicLatencyEvent(int64_t duration_us) { - UMA_HISTOGRAM_TIMES("V8.GC.Event.MainThread.Full.Atomic.Cpp", - base::TimeDelta::FromMicroseconds(duration_us)); -} - // Helper function to convert a byte count to a KB count, capping at // INT_MAX if the number is larger than that. constexpr int32_t CappedSizeInKB(int64_t size_in_bytes) { @@ -179,31 +174,30 @@ void V8MetricsRecorder::AddMainThreadEvent( base::TimeDelta::FromMicroseconds( event.main_thread_cpp.sweep_wall_clock_duration_in_us)); - // Report latency metrics: + // Report atomic pause metrics: UMA_HISTOGRAM_TIMES( - "V8.GC.Event.MainThread.Full.Atomic.Mark.Cpp", + "V8.GC.Cycle.MainThread.Full.Atomic.Mark.Cpp", base::TimeDelta::FromMicroseconds( event.main_thread_atomic_cpp.mark_wall_clock_duration_in_us)); UMA_HISTOGRAM_TIMES( - "V8.GC.Event.MainThread.Full.Atomic.Weak.Cpp", + "V8.GC.Cycle.MainThread.Full.Atomic.Weak.Cpp", base::TimeDelta::FromMicroseconds( event.main_thread_atomic_cpp.weak_wall_clock_duration_in_us)); UMA_HISTOGRAM_TIMES( - "V8.GC.Event.MainThread.Full.Atomic.Compact.Cpp", + "V8.GC.Cycle.MainThread.Full.Atomic.Compact.Cpp", base::TimeDelta::FromMicroseconds( event.main_thread_atomic_cpp.compact_wall_clock_duration_in_us)); UMA_HISTOGRAM_TIMES( - "V8.GC.Event.MainThread.Full.Atomic.Sweep.Cpp", + "V8.GC.Cycle.MainThread.Full.Atomic.Sweep.Cpp", + base::TimeDelta::FromMicroseconds( + event.main_thread_atomic_cpp.sweep_wall_clock_duration_in_us)); + UMA_HISTOGRAM_TIMES( + "V8.GC.Cycle.MainThread.Full.Atomic.Cpp", base::TimeDelta::FromMicroseconds( + event.main_thread_atomic_cpp.mark_wall_clock_duration_in_us + + event.main_thread_atomic_cpp.weak_wall_clock_duration_in_us + + event.main_thread_atomic_cpp.compact_wall_clock_duration_in_us + event.main_thread_atomic_cpp.sweep_wall_clock_duration_in_us)); - ReportAtomicLatencyEvent( - event.main_thread_atomic_cpp.mark_wall_clock_duration_in_us); - ReportAtomicLatencyEvent( - event.main_thread_atomic_cpp.weak_wall_clock_duration_in_us); - ReportAtomicLatencyEvent( - event.main_thread_atomic_cpp.compact_wall_clock_duration_in_us); - ReportAtomicLatencyEvent( - event.main_thread_atomic_cpp.sweep_wall_clock_duration_in_us); // Report size metrics: static constexpr size_t kMinSize = 1; diff --git a/tools/metrics/histograms/metadata/v8/histograms.xml b/tools/metrics/histograms/metadata/v8/histograms.xml index a144b43fc4396f..5f5f95903f42f2 100644 --- a/tools/metrics/histograms/metadata/v8/histograms.xml +++ b/tools/metrics/histograms/metadata/v8/histograms.xml @@ -457,6 +457,66 @@ reviews. Googlers can read more about this at go/gwsq-gerrit. + + omerkatz@chromium.org + v8-memory-sheriffs@google.com + + Overall duration of compaction on the main thread during the atomic pause of + a garbage collection of the managed C++ heap. There is only a single atomic + pause compaction event per cycle but it may cover several sub-events. + Reported at the end of the garbage collection cycle. + + + + + omerkatz@chromium.org + v8-memory-sheriffs@google.com + + Overall main thread duration of the atomic pause of a garbage collection of + the managed C++ heap. There is only a single atomic pause event per cycle + but it may cover several sub-events. Reported at the end of the garbage + collection cycle. + + + + + omerkatz@chromium.org + v8-memory-sheriffs@google.com + + Overall duration of marking on the main thread during the atomic pause of a + garbage collection of the managed C++ heap. There is only a single atomic + pause marking event per cycle but it may cover several sub-events. Reported + at the end of the garbage collection cycle. + + + + + omerkatz@chromium.org + v8-memory-sheriffs@google.com + + Overall duration of sweeping on the main thread during the atomic pasue of a + garbage collection of the managed C++ heap. There is only a single atomic + pause sweeping event per cycle but it may cover several sub-events. Reported + at the end of the garbage collection cycle. + + + + + omerkatz@chromium.org + v8-memory-sheriffs@google.com + + Overall duration of weakness handling on the main thread during the atomic + pause of a garbage collection of the managed C++ heap. There is only a + single atomic pause weakness handling event per cycle but it may cover + several sub-events. Reported at the end of the garbage collection cycle. + + + omerkatz@chromium.org @@ -553,6 +613,9 @@ reviews. Googlers can read more about this at go/gwsq-gerrit. + + Removed 09/2021. Renamed to V8.GC.Cycle.MainThread.Full.Atomic.Compact.Cpp. + omerkatz@chromium.org v8-memory-sheriffs@google.com @@ -563,6 +626,9 @@ reviews. Googlers can read more about this at go/gwsq-gerrit. + + Removed 09/2021. Renamed to V8.GC.Cycle.MainThread.Full.Atomic.Cpp. + omerkatz@chromium.org v8-memory-sheriffs@google.com @@ -573,6 +639,9 @@ reviews. Googlers can read more about this at go/gwsq-gerrit. + + Removed 09/2021. Renamed to V8.GC.Cycle.MainThread.Full.Atomic.Mark.Cpp. + omerkatz@chromium.org v8-memory-sheriffs@google.com @@ -583,6 +652,9 @@ reviews. Googlers can read more about this at go/gwsq-gerrit. + + Removed 09/2021. Renamed to V8.GC.Cycle.MainThread.Full.Atomic.Sweep.Cpp. + omerkatz@chromium.org v8-memory-sheriffs@google.com @@ -593,6 +665,9 @@ reviews. Googlers can read more about this at go/gwsq-gerrit. + + Removed 09/2021. Renamed to V8.GC.Cycle.MainThread.Full.Atomic.Weak.Cpp. + omerkatz@chromium.org v8-memory-sheriffs@google.com