Bug 1369538 - Telemetry MEDIACACHESTREAM_LENGTH_KB - r?cpearce,francois draft
authorGerald Squelart <gsquelart@mozilla.com>
Fri, 02 Jun 2017 10:43:45 +1200
changeset 588012 81dc218bc37235c5f4988c7d671aef4cd9575e94
parent 588008 fec3a4b50acd88df3b4af2dfe645a919713852a9
child 631433 876ba6833111c03d3f695c8de1128ba7805a12d4
push id61880
push usergsquelart@mozilla.com
push dateFri, 02 Jun 2017 01:36:07 +0000
reviewerscpearce, francois
bugs1369538
milestone55.0a1
Bug 1369538 - Telemetry MEDIACACHESTREAM_LENGTH_KB - r?cpearce,francois Capture each media stream's length (as provided, otherwise as actually downloaded), to gauge whether keeping media in memory would have a significant impact. MozReview-Commit-ID: 4yUQrbgLcGG
dom/media/MediaCache.cpp
toolkit/components/telemetry/Histograms.json
--- a/dom/media/MediaCache.cpp
+++ b/dom/media/MediaCache.cpp
@@ -1961,16 +1961,25 @@ MediaCacheStream::~MediaCacheStream()
   NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
   NS_ASSERTION(!mPinCount, "Unbalanced Pin");
 
   if (gMediaCache) {
     NS_ASSERTION(mClosed, "Stream was not closed");
     gMediaCache->ReleaseStream(this);
     MediaCache::MaybeShutdown();
   }
+
+  uint32_t lengthKb = uint32_t(
+    std::min(std::max(mStreamLength, int64_t(0)) / 1024, int64_t(UINT32_MAX)));
+  LOG("MediaCacheStream::~MediaCacheStream(this=%p) "
+      "MEDIACACHESTREAM_LENGTH_KB=%" PRIu32,
+      this,
+      lengthKb);
+  Telemetry::Accumulate(Telemetry::HistogramID::MEDIACACHESTREAM_LENGTH_KB,
+                        lengthKb);
 }
 
 void
 MediaCacheStream::SetTransportSeekable(bool aIsTransportSeekable)
 {
   ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
   NS_ASSERTION(mIsTransportSeekable || aIsTransportSeekable ||
                mChannelOffset == 0, "channel offset must be zero when we become non-seekable");
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -8393,16 +8393,26 @@
     "record_in_processes": ["main", "content"],
     "alert_emails": ["gsquelart@mozilla.com"],
     "bug_numbers": [1366936],
     "expires_in_version": "60",
     "kind": "enumerated",
     "n_values": 32,
     "description": "Maximum number of owners for each MediaCache block. Recorded at every MediaCache destruction, i.e., whenever there is no more media data to be downloaded or kept for playback."
   },
+  "MEDIACACHESTREAM_LENGTH_KB": {
+    "record_in_processes": ["main", "content"],
+    "alert_emails": ["gsquelart@mozilla.com"],
+    "bug_numbers": [1369538],
+    "expires_in_version": "60",
+    "kind": "linear",
+    "high": 520000,
+    "n_buckets": 66,
+    "description": "MediaCacheStream stream length size in KB; Either known size from the HTTP header if available, or otherwise the size actually downloaded. Recorded at every MediaCacheStream destruction."
+  },
   "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]