Skip to content

Commit

Permalink
Track decode & upload times for all image types
Browse files Browse the repository at this point in the history
There is currently tracking for decode and upload timing. But this is
only for Jpeg and WebP. We want to also track other image types. For
now, there is explicit interest in gif decode times. But having
individualized times per format would be useful.

This CL separates the "other" category out into explicit image formats
such as bmp, gif, ico, and png. The "other" category is maintained for
non-codec-backed images.

Bug: 1094716
Change-Id: I1edba285ca7c0840a206dd778393c0db7c372482
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2246947
Reviewed-by: Brian White <bcwhite@chromium.org>
Reviewed-by: Khushal <khushalsagar@chromium.org>
Commit-Queue: Chris Blume <cblume@chromium.org>
Cr-Commit-Position: refs/heads/master@{#779451}
  • Loading branch information
ProgramMax authored and Commit Bot committed Jun 17, 2020
1 parent 79d885e commit 6a67b36
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 29 deletions.
66 changes: 45 additions & 21 deletions cc/base/devtools_instrumentation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,34 @@ ScopedImageUploadTask::~ScopedImageUploadTask() {
return;

auto duration = base::TimeTicks::Now() - start_time_;
const char* histogram_name = nullptr;
switch (image_type_) {
case ImageType::kWebP:
UmaHistogramCustomMicrosecondsTimes(
"Renderer4.ImageUploadTaskDurationUs.WebP", duration, hist_min_,
hist_max_, bucket_count_);
case ImageType::kAvif:
histogram_name = "Renderer4.ImageUploadTaskDurationUs.Avif";
break;
case ImageType::kBmp:
histogram_name = "Renderer4.ImageUploadTaskDurationUs.Bmp";
break;
case ImageType::kGif:
histogram_name = "Renderer4.ImageUploadTaskDurationUs.Gif";
break;
case ImageType::kIco:
histogram_name = "Renderer4.ImageUploadTaskDurationUs.Ico";
break;
case ImageType::kJpeg:
UmaHistogramCustomMicrosecondsTimes(
"Renderer4.ImageUploadTaskDurationUs.Jpeg", duration, hist_min_,
hist_max_, bucket_count_);
histogram_name = "Renderer4.ImageUploadTaskDurationUs.Jpeg";
break;
case ImageType::kOther:
UmaHistogramCustomMicrosecondsTimes(
"Renderer4.ImageUploadTaskDurationUs.Other", duration, hist_min_,
hist_max_, bucket_count_);
case ImageType::kPng:
histogram_name = "Renderer4.ImageUploadTaskDurationUs.Png";
break;
case ImageType::kWebP:
histogram_name = "Renderer4.ImageUploadTaskDurationUs.WebP";
break;
case ImageType::kOther:
histogram_name = "Renderer4.ImageUploadTaskDurationUs.Other";
}
UmaHistogramCustomMicrosecondsTimes(histogram_name, duration, hist_min_,
hist_max_, bucket_count_);
}

ScopedImageDecodeTask::ScopedImageDecodeTask(const void* image_ptr,
Expand All @@ -104,23 +115,36 @@ ScopedImageDecodeTask::~ScopedImageDecodeTask() {
return;

auto duration = base::TimeTicks::Now() - start_time_;
const char* histogram_name = nullptr;
switch (image_type_) {
case ImageType::kWebP:
RecordMicrosecondTimesUmaByDecodeType(
"Renderer4.ImageDecodeTaskDurationUs.WebP", duration, hist_min_,
hist_max_, bucket_count_, decode_type_);
case ImageType::kAvif:
histogram_name = "Renderer4.ImageDecodeTaskDurationUs.Avif";
break;
case ImageType::kBmp:
histogram_name = "Renderer4.ImageDecodeTaskDurationUs.Bmp";
break;
case ImageType::kGif:
histogram_name = "Renderer4.ImageDecodeTaskDurationUs.Gif";
break;
case ImageType::kIco:
histogram_name = "Renderer4.ImageDecodeTaskDurationUs.Ico";
break;
case ImageType::kJpeg:
RecordMicrosecondTimesUmaByDecodeType(
"Renderer4.ImageDecodeTaskDurationUs.Jpeg", duration, hist_min_,
hist_max_, bucket_count_, decode_type_);
histogram_name = "Renderer4.ImageDecodeTaskDurationUs.Jpeg";
break;
case ImageType::kPng:
histogram_name = "Renderer4.ImageDecodeTaskDurationUs.Png";
break;
case ImageType::kWebP:
histogram_name = "Renderer4.ImageDecodeTaskDurationUs.WebP";
break;
case ImageType::kOther:
RecordMicrosecondTimesUmaByDecodeType(
"Renderer4.ImageDecodeTaskDurationUs.Other", duration, hist_min_,
hist_max_, bucket_count_, decode_type_);
histogram_name = "Renderer4.ImageDecodeTaskDurationUs.Other";
break;
}
RecordMicrosecondTimesUmaByDecodeType(histogram_name, duration, hist_min_,
hist_max_, bucket_count_, decode_type_);

switch (task_type_) {
case kInRaster:
RecordMicrosecondTimesUmaByDecodeType(
Expand Down
4 changes: 2 additions & 2 deletions cc/base/devtools_instrumentation.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ class CC_BASE_EXPORT ScopedLayerTask {

class CC_BASE_EXPORT ScopedImageTask {
public:
enum ImageType { kWebP, kJpeg, kOther };
enum ImageType { kAvif, kBmp, kGif, kIco, kJpeg, kPng, kWebP, kOther };

ScopedImageTask(ImageType image_type)
explicit ScopedImageTask(ImageType image_type)
: image_type_(image_type), start_time_(base::TimeTicks::Now()) {}
ScopedImageTask(const ScopedImageTask&) = delete;
~ScopedImageTask() = default;
Expand Down
23 changes: 18 additions & 5 deletions cc/tiles/image_decode_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,24 @@ class CC_EXPORT ImageDecodeCache {
ToScopedImageType(ImageType image_type) {
using ScopedImageType =
devtools_instrumentation::ScopedImageDecodeTask::ImageType;
if (image_type == ImageType::kWEBP)
return ScopedImageType::kWebP;
if (image_type == ImageType::kJPEG)
return ScopedImageType::kJpeg;
return ScopedImageType::kOther;
switch (image_type) {
case ImageType::kAVIF:
return ScopedImageType::kAvif;
case ImageType::kBMP:
return ScopedImageType::kBmp;
case ImageType::kGIF:
return ScopedImageType::kGif;
case ImageType::kICO:
return ScopedImageType::kIco;
case ImageType::kJPEG:
return ScopedImageType::kJpeg;
case ImageType::kPNG:
return ScopedImageType::kPng;
case ImageType::kWEBP:
return ScopedImageType::kWebP;
case ImageType::kInvalid:
return ScopedImageType::kOther;
}
}

virtual ~ImageDecodeCache() {}
Expand Down
12 changes: 11 additions & 1 deletion tools/metrics/histograms/histograms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -196783,10 +196783,20 @@ regressions. -->
<histogram_suffixes name="DecodedImageType" separator=".">
<!-- Name completed by histogram_suffixes name="RasterTaskType" -->

<suffix base="true" name="Avif"
label="This metric is for only Avif image types."/>
<suffix base="true" name="Bmp"
label="This metric is for only Bmp image types."/>
<suffix base="true" name="Gif"
label="This metric is for only Gif image types."/>
<suffix base="true" name="Ico"
label="This metric is for only Ico image types."/>
<suffix base="true" name="Jpeg"
label="This metric is for only Jpeg image types."/>
<suffix base="true" name="Other"
label="This metric is for non-WebP and non-Jpeg image types."/>
label="This metric is for non-codec-backed lazy images."/>
<suffix base="true" name="Png"
label="This metric is for only Png image types."/>
<suffix base="true" name="WebP"
label="This metric is for only WebP image types."/>
<affected-histogram name="Renderer4.ImageDecodeTaskDurationUs"/>
Expand Down

0 comments on commit 6a67b36

Please sign in to comment.