Bug 1297790 - Add telemetry probes for GPU process launch/launch-time/abort r=dvander
☠☠ backed out by 2777fabbe62a ☠ ☠
authorGeorge Wright <george@mozilla.com>
Thu, 20 Oct 2016 11:33:40 -0400
changeset 320077 0a1486cf11b228e41d27499b79b1e3ea6be3e28f
parent 320076 73aacf4a8f568cfd66a7a306cce0879bbdd5de5b
child 320078 33c2241696c07a203f5355771a40a8c28a0767b5
push id20749
push userryanvm@gmail.com
push dateSat, 29 Oct 2016 13:21:21 +0000
treeherderfx-team@1b170b39ed6b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdvander
bugs1297790
milestone52.0a1
Bug 1297790 - Add telemetry probes for GPU process launch/launch-time/abort r=dvander
gfx/ipc/GPUChild.cpp
gfx/ipc/GPUProcessHost.cpp
gfx/ipc/GPUProcessHost.h
toolkit/components/telemetry/Histograms.json
--- a/gfx/ipc/GPUChild.cpp
+++ b/gfx/ipc/GPUChild.cpp
@@ -2,16 +2,17 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=99: */
 /* 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/. */
 #include "GPUChild.h"
 #include "gfxConfig.h"
 #include "gfxPrefs.h"
 #include "GPUProcessHost.h"
+#include "mozilla/Telemetry.h"
 #include "mozilla/dom/CheckerboardReportService.h"
 #include "mozilla/gfx/gfxVars.h"
 #if defined(XP_WIN)
 # include "mozilla/gfx/DeviceManagerDx.h"
 #endif
 #include "mozilla/ipc/CrashReporterHost.h"
 
 namespace mozilla {
@@ -74,28 +75,30 @@ GPUChild::EnsureGPUReady()
   if (mGPUReady) {
     return;
   }
 
   GPUDeviceData data;
   SendGetDeviceStatus(&data);
 
   gfxPlatform::GetPlatform()->ImportGPUDeviceData(data);
+  Telemetry::AccumulateTimeDelta(Telemetry::GPU_PROCESS_LAUNCH_TIME_MS, mHost->GetLaunchTime());
   mGPUReady = true;
 }
 
 bool
 GPUChild::RecvInitComplete(const GPUDeviceData& aData)
 {
   // We synchronously requested GPU parameters before this arrived.
   if (mGPUReady) {
     return true;
   }
 
   gfxPlatform::GetPlatform()->ImportGPUDeviceData(aData);
+  Telemetry::AccumulateTimeDelta(Telemetry::GPU_PROCESS_LAUNCH_TIME_MS, mHost->GetLaunchTime());
   mGPUReady = true;
   return true;
 }
 
 bool
 GPUChild::RecvReportCheckerboard(const uint32_t& aSeverity, const nsCString& aLog)
 {
   layers::CheckerboardEventStorage::Report(aSeverity, std::string(aLog.get()));
@@ -139,16 +142,18 @@ GPUChild::ActorDestroy(ActorDestroyReaso
 {
   if (aWhy == AbnormalShutdown) {
 #ifdef MOZ_CRASHREPORTER
     if (mCrashReporter) {
       mCrashReporter->GenerateCrashReport(OtherPid());
       mCrashReporter = nullptr;
     }
 #endif
+    Telemetry::Accumulate(Telemetry::SUBPROCESS_ABNORMAL_ABORT,
+        nsDependentCString(XRE_ChildProcessTypeToString(GeckoProcessType_GPU), 1));
   }
 
   gfxVars::RemoveReceiver(this);
   mHost->OnChannelClosed();
 }
 
 class DeferredDeleteGPUChild : public Runnable
 {
--- a/gfx/ipc/GPUProcessHost.cpp
+++ b/gfx/ipc/GPUProcessHost.cpp
@@ -34,16 +34,18 @@ GPUProcessHost::~GPUProcessHost()
 
 bool
 GPUProcessHost::Launch()
 {
   MOZ_ASSERT(mLaunchPhase == LaunchPhase::Unlaunched);
   MOZ_ASSERT(!mGPUChild);
 
   mLaunchPhase = LaunchPhase::Waiting;
+  mLaunchTime = TimeStamp::Now();
+
   if (!GeckoChildProcessHost::AsyncLaunch()) {
     mLaunchPhase = LaunchPhase::Complete;
     return false;
   }
   return true;
 }
 
 bool
--- a/gfx/ipc/GPUProcessHost.h
+++ b/gfx/ipc/GPUProcessHost.h
@@ -77,16 +77,24 @@ public:
   // Return a unique id for this process, guaranteed not to be shared with any
   // past or future instance of GPUProcessHost.
   uint64_t GetProcessToken() const;
 
   bool IsConnected() const {
     return !!mGPUChild;
   }
 
+  // Return the time stamp for when we tried to launch the GPU process. This is
+  // currently used for Telemetry so that we can determine how long GPU processes
+  // take to spin up. Note this doesn't denote a successful launch, just when we
+  // attempted launch.
+  TimeStamp GetLaunchTime() const {
+    return mLaunchTime;
+  }
+
   // Called on the IO thread.
   void OnChannelConnected(int32_t peer_pid) override;
   void OnChannelError() override;
 
   void SetListener(Listener* aListener);
 
 private:
   // Called on the main thread.
@@ -117,14 +125,16 @@ private:
   };
   LaunchPhase mLaunchPhase;
 
   UniquePtr<GPUChild> mGPUChild;
   uint64_t mProcessToken;
 
   bool mShutdownRequested;
   bool mChannelClosed;
+
+  TimeStamp mLaunchTime;
 };
 
 } // namespace gfx
 } // namespace mozilla
 
 #endif // _include_mozilla_gfx_ipc_GPUProcessHost_h_
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -947,16 +947,26 @@
   },
   "GEOLOCATION_WATCHPOSITION_VISIBLE": {
     "alert_emails": ["michelangelo@mozilla.com"],
     "expires_in_version": "55",
     "kind": "boolean",
     "bug_numbers": [1255198],
     "description": "This metric is recorded every time a navigator.geolocation.watchPosition() request gets allowed/fulfilled. A false value is recorded if the owner is not visible according to document.isVisible."
   },
+  "GPU_PROCESS_LAUNCH_TIME_MS" : {
+    "alert_emails": ["george@mozilla.com", "danderson@mozilla.com"],
+    "expires_in_version": "never",
+    "bug_numbers": [1297790],
+    "kind": "exponential",
+    "high": 1000,
+    "n_buckets": 50,
+    "releaseChannelCollection": "opt-out",
+    "description": "GPU process launch time in milliseconds"
+  },
   "JS_DEPRECATED_LANGUAGE_EXTENSIONS_IN_CONTENT": {
     "alert_emails": ["jdemooij@mozilla.com"],
     "expires_in_version": "never",
     "kind": "enumerated",
     "n_values": 10,
     "description": "Use of SpiderMonkey's deprecated language extensions in web content: ForEach=0, DestructuringForIn=1 (obsolete), LegacyGenerator=2, ExpressionClosure=3, LetBlock=4 (obsolete), LetExpression=5 (obsolete), NoSuchMethod=6 (obsolete), FlagsArgument=7 (obsolete), RegExpSourceProp=8 (obsolete), RestoredRegExpStatics=9 (obsolete), BlockScopeFunRedecl=10"
   },
   "JS_DEPRECATED_LANGUAGE_EXTENSIONS_IN_ADDONS": {