From 9b56ccfb99b73f67ba122b9f11ac864716e93a3f Mon Sep 17 00:00:00 2001 From: Avi Halachmi Date: Wed, 16 Dec 2015 20:06:40 +0200 Subject: [PATCH] Bug 1228147: part 2: Add telemetry probe for synchronous scroll. r=kats --- layout/base/nsRefreshDriver.cpp | 10 ++++++++-- layout/generic/nsGfxScrollFrame.cpp | 12 +++++++++++- toolkit/components/telemetry/Histograms.json | 9 +++++++++ toolkit/components/telemetry/Telemetry.cpp | 1 + 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/layout/base/nsRefreshDriver.cpp b/layout/base/nsRefreshDriver.cpp index 03478544d5a8..0248232ed93d 100644 --- a/layout/base/nsRefreshDriver.cpp +++ b/layout/base/nsRefreshDriver.cpp @@ -441,8 +441,11 @@ private: #ifndef ANDROID /* bug 1142079 */ if (XRE_IsParentProcess()) { TimeDuration vsyncLatency = TimeStamp::Now() - aVsyncTimestamp; + uint32_t sample = (uint32_t)vsyncLatency.ToMilliseconds(); Telemetry::Accumulate(Telemetry::FX_REFRESH_DRIVER_CHROME_FRAME_DELAY_MS, - vsyncLatency.ToMilliseconds()); + sample); + Telemetry::Accumulate(Telemetry::FX_REFRESH_DRIVER_SYNC_SCROLL_FRAME_DELAY_MS, + sample); } else if (mVsyncRate != TimeDuration::Forever()) { TimeDuration contentDelay = (TimeStamp::Now() - mLastChildTick) - mVsyncRate; if (contentDelay.ToMilliseconds() < 0 ){ @@ -450,8 +453,11 @@ private: // the reported hardware rate. In those cases, consider that we have 0 delay. contentDelay = TimeDuration::FromMilliseconds(0); } + uint32_t sample = (uint32_t)contentDelay.ToMilliseconds(); Telemetry::Accumulate(Telemetry::FX_REFRESH_DRIVER_CONTENT_FRAME_DELAY_MS, - contentDelay.ToMilliseconds()); + sample); + Telemetry::Accumulate(Telemetry::FX_REFRESH_DRIVER_SYNC_SCROLL_FRAME_DELAY_MS, + sample); } else { // Request the vsync rate from the parent process. Might be a few vsyncs // until the parent responds. diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index 5f65d40f8c6c..19ebdaa671bc 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -41,6 +41,7 @@ #include "mozilla/dom/Element.h" #include #include "mozilla/MathAlgorithms.h" +#include "mozilla/Telemetry.h" #include "FrameLayerBuilder.h" #include "nsSMILKeySpline.h" #include "nsSubDocumentFrame.h" @@ -1510,6 +1511,8 @@ public: , mCallee(nullptr) , mOneDevicePixelInAppUnits(aPresContext->DevPixelsToAppUnits(1)) { + Telemetry::SetHistogramRecordingEnabled( + Telemetry::FX_REFRESH_DRIVER_SYNC_SCROLL_FRAME_DELAY_MS, true); } NS_INLINE_DECL_REFCOUNTING(AsyncSmoothMSDScroll, override) @@ -1598,6 +1601,8 @@ private: // Private destructor, to discourage deletion outside of Release(): ~AsyncSmoothMSDScroll() { RemoveObserver(); + Telemetry::SetHistogramRecordingEnabled( + Telemetry::FX_REFRESH_DRIVER_SYNC_SCROLL_FRAME_DELAY_MS, false); } nsRefreshDriver* RefreshDriver(ScrollFrameHelper* aCallee) { @@ -1634,12 +1639,17 @@ public: explicit AsyncScroll(nsPoint aStartPos) : AsyncScrollBase(aStartPos) , mCallee(nullptr) - {} + { + Telemetry::SetHistogramRecordingEnabled( + Telemetry::FX_REFRESH_DRIVER_SYNC_SCROLL_FRAME_DELAY_MS, true); + } private: // Private destructor, to discourage deletion outside of Release(): ~AsyncScroll() { RemoveObserver(); + Telemetry::SetHistogramRecordingEnabled( + Telemetry::FX_REFRESH_DRIVER_SYNC_SCROLL_FRAME_DELAY_MS, false); } public: diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json index 8f568414ae2d..e0dea035cd77 100644 --- a/toolkit/components/telemetry/Histograms.json +++ b/toolkit/components/telemetry/Histograms.json @@ -4135,6 +4135,15 @@ "bug_numbers": [1221674], "description": "Delay in ms between the target and the actual handling time of the frame at refresh driver in the content process." }, + "FX_REFRESH_DRIVER_SYNC_SCROLL_FRAME_DELAY_MS": { + "alert_emails": ["perf-telemetry-alerts@mozilla.com"], + "expires_in_version": "never", + "kind": "exponential", + "high": "10000", + "n_buckets": 50, + "bug_numbers": [1228147], + "description": "Delay in ms between the target and the actual handling time of the frame at refresh driver while scrolling synchronously." + }, "FX_TAB_SWITCH_UPDATE_MS": { "alert_emails": ["perf-telemetry-alerts@mozilla.com"], "expires_in_version": "never", diff --git a/toolkit/components/telemetry/Telemetry.cpp b/toolkit/components/telemetry/Telemetry.cpp index 62dff73b199f..f5106b8f2c17 100644 --- a/toolkit/components/telemetry/Telemetry.cpp +++ b/toolkit/components/telemetry/Telemetry.cpp @@ -909,6 +909,7 @@ IsHistogramEnumId(Telemetry::ID aID) // List of histogram IDs which should have recording disabled initially. const Telemetry::ID kRecordingInitiallyDisabledIDs[] = { + Telemetry::FX_REFRESH_DRIVER_SYNC_SCROLL_FRAME_DELAY_MS, // The array must not be empty. Leave these item here. Telemetry::TELEMETRY_TEST_COUNT_INIT_NO_RECORD,