Bug 1524090. Add telemetry for GPU wait time. r=mattwoodrow,chutten
☠☠ backed out by 2a08410b3cdc ☠ ☠
authorJeff Muizelaar <jrmuizel@gmail.com>
Tue, 05 Mar 2019 21:35:33 +0000
changeset 521590 5b73beb33ff14ddd5e197cee1bf1dc9c0ca71cff
parent 521589 0cc7b558b836c8f36e53bf6941f7425e134383a9
child 521591 51fd0edf687f5105aac2d3366d6c30dc286490af
push id10867
push userdvarga@mozilla.com
push dateThu, 14 Mar 2019 15:20:45 +0000
treeherdermozilla-beta@abad13547875 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow, chutten
bugs1524090
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1524090. Add telemetry for GPU wait time. r=mattwoodrow,chutten Differential Revision: https://phabricator.services.mozilla.com/D22100
gfx/layers/d3d11/CompositorD3D11.cpp
gfx/layers/d3d11/HelpersD3D11.h
gfx/layers/d3d11/MLGDeviceD3D11.cpp
gfx/webrender_bindings/RenderCompositorANGLE.cpp
toolkit/components/telemetry/Histograms.json
--- a/gfx/layers/d3d11/CompositorD3D11.cpp
+++ b/gfx/layers/d3d11/CompositorD3D11.cpp
@@ -1247,17 +1247,17 @@ void CompositorD3D11::EndFrame() {
     }
   } else {
     mDiagnostics->Cancel();
   }
 
   // Block until the previous frame's work has been completed.
   if (mQuery) {
     BOOL result;
-    WaitForGPUQuery(mDevice, mContext, mQuery, &result);
+    WaitForFrameGPUQuery(mDevice, mContext, mQuery, &result);
   }
   // Store the query for this frame so we can flush it next time.
   mQuery = query;
 
   Compositor::EndFrame();
 
   mCurrentRT = nullptr;
 }
--- a/gfx/layers/d3d11/HelpersD3D11.h
+++ b/gfx/layers/d3d11/HelpersD3D11.h
@@ -3,16 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_gfx_layers_d3d11_HelpersD3D11_h
 #define mozilla_gfx_layers_d3d11_HelpersD3D11_h
 
 #include <d3d11.h>
+#include "mozilla/Telemetry.h"
 #include "mozilla/TimeStamp.h"
 
 namespace mozilla {
 namespace layers {
 
 template <typename T>
 static inline bool WaitForGPUQuery(ID3D11Device* aDevice,
                                    ID3D11DeviceContext* aContext,
@@ -25,12 +26,31 @@ static inline bool WaitForGPUQuery(ID3D1
     if (TimeStamp::Now() - start > TimeDuration::FromSeconds(2)) {
       return false;
     }
     Sleep(0);
   }
   return true;
 }
 
+static inline bool WaitForFrameGPUQuery(ID3D11Device* aDevice,
+                                   ID3D11DeviceContext* aContext,
+                                   ID3D11Query* aQuery, bool* aOut) {
+  TimeStamp start = TimeStamp::Now();
+  bool success = true;
+  while (aContext->GetData(aQuery, aOut, sizeof(*aOut), 0) != S_OK) {
+    if (aDevice->GetDeviceRemovedReason() != S_OK) {
+      return false;
+    }
+    if (TimeStamp::Now() - start > TimeDuration::FromSeconds(2)) {
+      success = false;
+      break;
+    }
+    Sleep(0);
+  }
+  Telemetry::AccumulateTimeDelta(Telemetry::GPU_WAIT_TIME_MS, start);
+  return success;
+}
+
 }  // namespace layers
 }  // namespace mozilla
 
 #endif  // mozilla_gfx_layers_d3d11_HelpersD3D11_h
--- a/gfx/layers/d3d11/MLGDeviceD3D11.cpp
+++ b/gfx/layers/d3d11/MLGDeviceD3D11.cpp
@@ -1781,17 +1781,17 @@ void MLGDeviceD3D11::InsertPresentWaitQu
   }
 
   mCtx->End(mNextWaitForPresentQuery);
 }
 
 void MLGDeviceD3D11::WaitForPreviousPresentQuery() {
   if (mWaitForPresentQuery) {
     BOOL result;
-    WaitForGPUQuery(mDevice, mCtx, mWaitForPresentQuery, &result);
+    WaitForFrameGPUQuery(mDevice, mCtx, mWaitForPresentQuery, &result);
   }
   mWaitForPresentQuery = mNextWaitForPresentQuery.forget();
 }
 
 void MLGDeviceD3D11::Flush() { mCtx->Flush(); }
 
 void MLGDeviceD3D11::EndFrame() {
   // On our Windows 8 x64 machines, we have observed a driver bug related to
--- a/gfx/webrender_bindings/RenderCompositorANGLE.cpp
+++ b/gfx/webrender_bindings/RenderCompositorANGLE.cpp
@@ -505,17 +505,17 @@ void RenderCompositorANGLE::InsertPresen
 }
 
 void RenderCompositorANGLE::WaitForPreviousPresentQuery() {
   size_t waitLatency = mUseTripleBuffering ? 3 : 2;
 
   while (mWaitForPresentQueries.size() >= waitLatency) {
     RefPtr<ID3D11Query>& query = mWaitForPresentQueries.front();
     BOOL result;
-    layers::WaitForGPUQuery(mDevice, mCtx, query, &result);
+    layers::WaitForFrameGPUQuery(mDevice, mCtx, query, &result);
 
     // Recycle query for later use.
     mRecycledQuery = query;
     mWaitForPresentQueries.pop();
   }
 }
 
 }  // namespace wr
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -13227,16 +13227,27 @@
     "expires_in_version": "72",
     "keyed": true,
     "keys": ["dl", "flb", "fr", "r"],
     "kind": "linear",
     "high": 100,
     "n_buckets": 10,
     "description": "Percentages of times for phases in a normal content paint relative to the time spent in the entire normal paint. (\"dl\" = Display list, \"flb\" = Frame layer builder, \"fr\" = Flush rasterization, \"r\" = Rasterization)"
   },
+  "GPU_WAIT_TIME_MS": {
+    "record_in_processes": ["main", "gpu"],
+    "alert_emails": ["gfx-telemetry-alerts@mozilla.com", "jmuizelaar@mozilla.com"],
+    "bug_numbers": [1524090],
+    "expires_in_version": "82",
+    "releaseChannelCollection": "opt-out",
+    "kind": "exponential",
+    "high": 5000,
+    "n_buckets": 50,
+    "description": "The number of milliseconds we spend waiting for the GPU"
+  },
   "NARRATE_CONTENT_BY_LANGUAGE_2": {
     "record_in_processes": ["main", "content"],
     "alert_emails": ["eisaacson@mozilla.com"],
     "bug_numbers": [1308030, 1324868],
     "releaseChannelCollection": "opt-out",
     "expires_in_version": "60",
     "kind": "enumerated",
     "keyed": true,