Bug 1366639 - Add telemetry to track max number of PChromiumCDM video frame shmems. r=francois,gerald
authorChris Pearce <cpearce@mozilla.com>
Mon, 22 May 2017 15:03:00 +1200
changeset 360129 9bc41c3089925e4ef042af81b59a6269083100c5
parent 360128 09de5eeb4d2d3d3237982ff533c73dc72a53a43e
child 360130 8818d31a2a397ff86a4b843e11ed0ba31c4c8f3e
push id31868
push userryanvm@gmail.com
push dateTue, 23 May 2017 14:32:52 +0000
treeherdermozilla-central@3a82a745123f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfrancois, gerald
bugs1366639
milestone55.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 1366639 - Add telemetry to track max number of PChromiumCDM video frame shmems. r=francois,gerald This will enable us to pre-allocate the correct number of shared memory buffers that we pre-allocate for sending video frames between the CDM and Gecko. That means we won't need to take the slow path to recover from underestimating how many shmems we need. MozReview-Commit-ID: Q4mX2rYMz3
dom/media/gmp/ChromiumCDMParent.cpp
dom/media/gmp/ChromiumCDMParent.h
toolkit/components/telemetry/Histograms.json
--- a/dom/media/gmp/ChromiumCDMParent.cpp
+++ b/dom/media/gmp/ChromiumCDMParent.cpp
@@ -5,16 +5,17 @@
 
 #include "ChromiumCDMParent.h"
 #include "mozilla/gmp/GMPTypes.h"
 #include "GMPContentChild.h"
 #include "GMPContentParent.h"
 #include "mozilla/Unused.h"
 #include "ChromiumCDMProxy.h"
 #include "mozilla/dom/MediaKeyMessageEventBinding.h"
+#include "mozilla/Telemetry.h"
 #include "content_decryption_module.h"
 #include "GMPLog.h"
 #include "MediaPrefs.h"
 #include "GMPUtils.h"
 
 namespace mozilla {
 namespace gmp {
 
@@ -691,16 +692,20 @@ ChromiumCDMParent::EnsureSufficientShmem
   }
 
   while (mVideoShmemsActive < mVideoShmemLimit) {
     if (!SendBufferToCDM(mVideoFrameBufferSize)) {
       return false;
     }
     mVideoShmemsActive++;
   }
+
+  mMaxVideoShmemsActive =
+    std::max(mMaxVideoShmemsActive, mVideoShmemsActive);
+
   return true;
 }
 
 ipc::IPCResult
 ChromiumCDMParent::RecvDecodedData(const CDMVideoFrame& aFrame,
                                    nsTArray<uint8_t>&& aData)
 {
   GMP_LOG("ChromiumCDMParent::RecvDecodedData(this=%p)", this);
@@ -1046,16 +1051,23 @@ ChromiumCDMParent::ShutdownVideoDecoder(
                                           __func__);
   mDecodePromise.RejectIfExists(NS_ERROR_DOM_MEDIA_CANCELED, __func__);
   MOZ_ASSERT(mFlushDecoderPromise.IsEmpty());
   if (!SendDeinitializeVideoDecoder()) {
     return ShutdownPromise::CreateAndResolve(true, __func__);
   }
   mVideoDecoderInitialized = false;
 
+  GMP_LOG("ChromiumCDMParent::~ShutdownVideoDecoder(this=%p) "
+          "VIDEO_CHROMIUM_CDM_MAX_SHMEMS=%u",
+          this,
+          mMaxVideoShmemsActive);
+  Telemetry::Accumulate(Telemetry::HistogramID::VIDEO_CHROMIUM_CDM_MAX_SHMEMS,
+                        mMaxVideoShmemsActive);
+
   // The ChromiumCDMChild will purge its shmems, so if the decoder is
   // reinitialized the shmems need to be re-allocated, and they may need
   // to be a different size.
   mVideoShmemsActive = 0;
   mVideoFrameBufferSize = 0;
   return ShutdownPromise::CreateAndResolve(true, __func__);
 }
 
--- a/dom/media/gmp/ChromiumCDMParent.h
+++ b/dom/media/gmp/ChromiumCDMParent.h
@@ -161,16 +161,18 @@ protected:
 
   size_t mVideoFrameBufferSize = 0;
 
   // Count of the number of shmems in the set used to return decoded video
   // frames from the CDM to Gecko.
   uint32_t mVideoShmemsActive = 0;
   // Maximum number of shmems to use to return decoded video frames.
   uint32_t mVideoShmemLimit;
+  // High water mark for mVideoShmemsActive, reported via telemetry.
+  uint32_t mMaxVideoShmemsActive = 0;
 
   bool mIsShutdown = false;
   bool mVideoDecoderInitialized = false;
   bool mActorDestroyed = false;
 };
 
 } // namespace gmp
 } // namespace mozilla
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -8326,16 +8326,25 @@
   "MEDIA_EME_SECURE_CONTEXT": {
     "record_in_processes": ["main", "content"],
     "alert_emails": ["cpearce@mozilla.com"],
     "expires_in_version": "60",
     "kind": "boolean",
     "description": "Reports whether a navigator.requestMediaKeySystemAccess() was called in a secure context (i.e. on an origin served over HTTPS) or not.",
     "bug_numbers": [1360438]
   },
+  "VIDEO_CHROMIUM_CDM_MAX_SHMEMS": {
+    "record_in_processes": ["main", "content"],
+    "alert_emails": ["cpearce@mozilla.com"],
+    "bug_numbers": [1366639],
+    "expires_in_version": "60",
+    "kind": "enumerated",
+    "n_values": 50,
+    "description": "Counts of the maximum number of shared memory buffers used for transferring video frames between the CDM and Gecko processes during playback of DRM'd video. Reported once per CDMVideoDecoder instance, i.e., once per JavaScript SourceBuffer during playback of video using EME."
+  },
   "VIDEO_MFT_OUTPUT_NULL_SAMPLES": {
     "record_in_processes": ["main", "content"],
     "alert_emails": ["cpearce@mozilla.com"],
     "expires_in_version": "53",
     "kind": "enumerated",
     "n_values": 10,
     "description": "Does the WMF video decoder return success but null output? 0 = playback successful, 1 = excessive null output but able to decode some frames, 2 = excessive null output and gave up, 3 = null output but recovered, 4 = non-excessive null output without being able to decode frames.",
     "bug_numbers": [1176071]