From b92ab8df04c4bcd81e50e44bafaad9e488a24f66 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Tue, 28 Nov 2017 03:16:26 -0800 Subject: [PATCH] Bug 1421195 - Add telemetry probe for fraction of restyles that are parallel ; r=emilio MozReview-Commit-ID: sVN7CWjgni --- layout/style/ServoBindings.cpp | 12 ++++++++++++ layout/style/ServoBindings.h | 1 + toolkit/components/telemetry/Histograms.json | 10 ++++++++++ 3 files changed, 23 insertions(+) diff --git a/layout/style/ServoBindings.cpp b/layout/style/ServoBindings.cpp index 1b8c03cad2d6..ea37fd20134e 100644 --- a/layout/style/ServoBindings.cpp +++ b/layout/style/ServoBindings.cpp @@ -65,6 +65,7 @@ #include "mozilla/StyleAnimationValue.h" #include "mozilla/SystemGroup.h" #include "mozilla/ServoMediaList.h" +#include "mozilla/Telemetry.h" #include "mozilla/RWLock.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/ElementInlines.h" @@ -122,6 +123,17 @@ AssertIsMainThreadOrServoLangFontPrefsCacheLocked() MOZ_ASSERT(NS_IsMainThread() || sServoFFILock->LockedForWritingByCurrentThread()); } + +void +Gecko_RecordTraversalStatistics(uint32_t total, uint32_t parallel) +{ + // we ignore cases where a page just didn't restyle a lot + if (total > 30) { + uint32_t percent = parallel * 100 / total; + Telemetry::Accumulate(Telemetry::STYLO_PARALLEL_RESTYLE_FRACTION, percent); + } +} + bool Gecko_IsInDocument(RawGeckoNodeBorrowed aNode) { diff --git a/layout/style/ServoBindings.h b/layout/style/ServoBindings.h index 7046e02d1423..18774b73f592 100644 --- a/layout/style/ServoBindings.h +++ b/layout/style/ServoBindings.h @@ -142,6 +142,7 @@ struct FontSizePrefs }; // DOM Traversal. +void Gecko_RecordTraversalStatistics(uint32_t total, uint32_t parallel); bool Gecko_IsInDocument(RawGeckoNodeBorrowed node); bool Gecko_FlattenedTreeParentIsParent(RawGeckoNodeBorrowed node); bool Gecko_IsSignificantChild(RawGeckoNodeBorrowed node, diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json index bd332c02beb6..1811f17ad065 100644 --- a/toolkit/components/telemetry/Histograms.json +++ b/toolkit/components/telemetry/Histograms.json @@ -13931,5 +13931,15 @@ "expires_in_version": "60", "kind": "boolean", "description": "Tracking how often scripts are loaded with a 'valid' version parameter. This telemetry ID helps us to decide if and when remove the support of script versioning." + }, + "STYLO_PARALLEL_RESTYLE_FRACTION": { + "record_in_processes": ["content"], + "alert_emails": ["manish@mozilla.com"], + "expires_in_version": "60", + "kind": "linear", + "high": 100, + "n_buckets": 50, + "description": "Fraction of restyles on a single page that were parallel", + "bug_numbers": [1421195] } }