Bug 825519 - Add telemetry for the max number of times any one image was decoded. r=joe
--- a/image/src/RasterImage.cpp
+++ b/image/src/RasterImage.cpp
@@ -62,16 +62,20 @@ GetCompressedImageAccountingLog()
// because otherwise, we have to initialize them in a static initializer, which
// makes us slower to start up.
static uint32_t gDecodeBytesAtATime = 0;
static uint32_t gMaxMSBeforeYield = 0;
static bool gHQDownscaling = false;
// This is interpreted as a floating-point value / 1000
static uint32_t gHQDownscalingMinFactor = 1000;
+// The maximum number of times any one RasterImage was decoded. This is only
+// used for statistics.
+static int32_t sMaxDecodeCount = 0;
+
static void
InitPrefCaches()
{
Preferences::AddUintVarCache(&gDecodeBytesAtATime,
"image.mem.decode_bytes_at_a_time", 200000);
Preferences::AddUintVarCache(&gMaxMSBeforeYield,
"image.mem.max_ms_before_yield", 400);
Preferences::AddBoolVarCache(&gHQDownscaling,
@@ -2568,16 +2572,26 @@ RasterImage::InitDecoder(bool aDoSizeDec
mDecoder->SetDecodeFlags(mFrameDecodeFlags);
mDecoder->Init();
CONTAINER_ENSURE_SUCCESS(mDecoder->GetDecoderError());
if (!aDoSizeDecode) {
Telemetry::GetHistogramById(Telemetry::IMAGE_DECODE_COUNT)->Subtract(mDecodeCount);
mDecodeCount++;
Telemetry::GetHistogramById(Telemetry::IMAGE_DECODE_COUNT)->Add(mDecodeCount);
+
+ if (mDecodeCount > sMaxDecodeCount) {
+ // Don't subtract out 0 from the histogram, because that causes its count
+ // to go negative, which is not kosher.
+ if (sMaxDecodeCount > 0) {
+ Telemetry::GetHistogramById(Telemetry::IMAGE_MAX_DECODE_COUNT)->Subtract(sMaxDecodeCount);
+ }
+ sMaxDecodeCount = mDecodeCount;
+ Telemetry::GetHistogramById(Telemetry::IMAGE_MAX_DECODE_COUNT)->Add(sMaxDecodeCount);
+ }
}
return NS_OK;
}
// Flushes, closes, and nulls-out a decoder. Cleans up any related decoding
// state. It is an error to call this function when there is no initialized
// decoder.
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -502,16 +502,22 @@
"description": "Number of chunks per decode attempt"
},
"IMAGE_DECODE_COUNT": {
"kind": "exponential",
"high": "500",
"n_buckets": 50,
"description": "Decode count"
},
+ "IMAGE_MAX_DECODE_COUNT": {
+ "kind": "exponential",
+ "high": "10000",
+ "n_buckets": 100,
+ "description": "Max decode count over all images"
+ },
"IMAGE_DECODE_SPEED_JPEG": {
"kind": "exponential",
"low": 500,
"high": "50000000",
"n_buckets": 50,
"description": "JPEG image decode speed (Kbytes/sec)"
},
"IMAGE_DECODE_SPEED_GIF": {