Commit 39c04073 authored by ckitagawa's avatar ckitagawa Committed by Commit Bot

[Paint Preview] Usage, Time and Frame Count UMA

This adds UMA metrics for
- Capture time in spent in Blink
- Total capture time
- Usage/Success counters
- Frame count to evaluate total frames captured

Follow-up CLs will be needed for UKMs and disk-usage.

Bug: 1038390
Change-Id: I1b7e0a844da23d23257cb75ad6673ff31a730955
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1986773Reviewed-by: default avatarAlexei Svitkine <asvitkine@chromium.org>
Reviewed-by: default avatarIan Vollick <vollick@chromium.org>
Commit-Queue: Calder Kitagawa <ckitagawa@chromium.org>
Cr-Commit-Position: refs/heads/master@{#734644}
parent a2e0f374
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "base/callback.h" #include "base/callback.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/task/post_task.h" #include "base/metrics/histogram_functions.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "components/keyed_service/core/keyed_service.h" #include "components/keyed_service/core/keyed_service.h"
#include "components/paint_preview/browser/compositor_utils.h" #include "components/paint_preview/browser/compositor_utils.h"
...@@ -98,10 +98,12 @@ void PaintPreviewBaseService::CapturePaintPreview( ...@@ -98,10 +98,12 @@ void PaintPreviewBaseService::CapturePaintPreview(
params.is_main_frame = (render_frame_host == web_contents->GetMainFrame()); params.is_main_frame = (render_frame_host == web_contents->GetMainFrame());
params.root_dir = root_dir; params.root_dir = root_dir;
auto start_time = base::TimeTicks::Now();
client->CapturePaintPreview( client->CapturePaintPreview(
params, render_frame_host, params, render_frame_host,
base::BindOnce(&PaintPreviewBaseService::OnCaptured, base::BindOnce(&PaintPreviewBaseService::OnCaptured,
weak_ptr_factory_.GetWeakPtr(), std::move(callback))); weak_ptr_factory_.GetWeakPtr(), start_time,
std::move(callback)));
} }
std::unique_ptr<PaintPreviewCompositorService> std::unique_ptr<PaintPreviewCompositorService>
...@@ -112,6 +114,7 @@ PaintPreviewBaseService::StartCompositorService( ...@@ -112,6 +114,7 @@ PaintPreviewBaseService::StartCompositorService(
} }
void PaintPreviewBaseService::OnCaptured( void PaintPreviewBaseService::OnCaptured(
base::TimeTicks start_time,
OnCapturedCallback callback, OnCapturedCallback callback,
base::UnguessableToken guid, base::UnguessableToken guid,
mojom::PaintPreviewStatus status, mojom::PaintPreviewStatus status,
...@@ -122,6 +125,8 @@ void PaintPreviewBaseService::OnCaptured( ...@@ -122,6 +125,8 @@ void PaintPreviewBaseService::OnCaptured(
std::move(callback).Run(kCaptureFailed, nullptr); std::move(callback).Run(kCaptureFailed, nullptr);
return; return;
} }
base::UmaHistogramTimes("Browser.PaintPreview.Capture.TotalCaptureDuration",
base::TimeTicks::Now() - start_time);
std::move(callback).Run(kOk, std::move(proto)); std::move(callback).Run(kOk, std::move(proto));
} }
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/optional.h" #include "base/optional.h"
#include "base/time/time.h"
#include "base/unguessable_token.h" #include "base/unguessable_token.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "components/keyed_service/core/keyed_service.h" #include "components/keyed_service/core/keyed_service.h"
...@@ -119,7 +120,8 @@ class PaintPreviewBaseService : public KeyedService { ...@@ -119,7 +120,8 @@ class PaintPreviewBaseService : public KeyedService {
#endif // defined(OS_ANDROID) #endif // defined(OS_ANDROID)
private: private:
void OnCaptured(OnCapturedCallback callback, void OnCaptured(base::TimeTicks start_time,
OnCapturedCallback callback,
base::UnguessableToken guid, base::UnguessableToken guid,
mojom::PaintPreviewStatus status, mojom::PaintPreviewStatus status,
std::unique_ptr<PaintPreviewProto> proto); std::unique_ptr<PaintPreviewProto> proto);
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <utility> #include <utility>
#include "base/metrics/histogram_functions.h"
#include "base/strings/strcat.h" #include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/task/post_task.h" #include "base/task/post_task.h"
...@@ -344,7 +345,14 @@ void PaintPreviewClient::OnFinished(base::UnguessableToken guid, ...@@ -344,7 +345,14 @@ void PaintPreviewClient::OnFinished(base::UnguessableToken guid,
PaintPreviewData* document_data) { PaintPreviewData* document_data) {
if (!document_data) if (!document_data)
return; return;
base::UmaHistogramBoolean("Browser.PaintPreview.Capture.Success",
document_data->proto != nullptr);
if (document_data->proto) { if (document_data->proto) {
base::UmaHistogramCounts100(
"Browser.PaintPreview.Capture.NumberOfFramesCaptured",
document_data->finished_subframes.size());
// At a minimum one frame was captured successfully, it is up to the // At a minimum one frame was captured successfully, it is up to the
// caller to decide if a partial success is acceptable based on what is // caller to decide if a partial success is acceptable based on what is
// contained in the proto. // contained in the proto.
......
...@@ -7,7 +7,9 @@ ...@@ -7,7 +7,9 @@
#include <utility> #include <utility>
#include "base/auto_reset.h" #include "base/auto_reset.h"
#include "base/metrics/histogram_functions.h"
#include "base/task_runner.h" #include "base/task_runner.h"
#include "base/time/time.h"
#include "cc/paint/paint_record.h" #include "cc/paint/paint_record.h"
#include "cc/paint/paint_recorder.h" #include "cc/paint/paint_recorder.h"
#include "components/paint_preview/renderer/paint_preview_recorder_utils.h" #include "components/paint_preview/renderer/paint_preview_recorder_utils.h"
...@@ -111,7 +113,35 @@ void PaintPreviewRecorderImpl::CapturePaintPreviewInternal( ...@@ -111,7 +113,35 @@ void PaintPreviewRecorderImpl::CapturePaintPreviewInternal(
cc::PaintCanvas* canvas = cc::PaintCanvas* canvas =
recorder.beginRecording(bounds.width(), bounds.height()); recorder.beginRecording(bounds.width(), bounds.height());
canvas->SetPaintPreviewTracker(&tracker); canvas->SetPaintPreviewTracker(&tracker);
// Use time ticks manually rather than a histogram macro so as to;
// 1. Account for main frames and subframes separately.
// 2. Mitigate binary size as this won't be used that often.
// 3. Record only on successes as failures are likely to be outliers (fast or
// slow).
base::TimeTicks start_time = base::TimeTicks::Now();
bool success = frame->CapturePaintPreview(bounds, canvas); bool success = frame->CapturePaintPreview(bounds, canvas);
base::TimeDelta capture_time = base::TimeTicks::Now() - start_time;
if (is_main_frame_) {
base::UmaHistogramBoolean("Renderer.PaintPreview.Capture.MainFrameSuccess",
success);
if (success) {
// Main frame should generally be the largest cost and will always run so
// it is tracked separately.
base::UmaHistogramTimes(
"Renderer.PaintPreview.Capture.MainFrameBlinkCaptureDuration",
capture_time);
}
} else {
base::UmaHistogramBoolean("Renderer.PaintPreview.Capture.SubframeSuccess",
success);
if (success) {
base::UmaHistogramTimes(
"Renderer.PaintPreview.Capture.SubframeBlinkCaptureDuration",
capture_time);
}
}
// Restore to before out-of-lifecycle paint phase. // Restore to before out-of-lifecycle paint phase.
frame->DispatchAfterPrintEvent(); frame->DispatchAfterPrintEvent();
......
...@@ -20176,6 +20176,37 @@ uploading your change for review. ...@@ -20176,6 +20176,37 @@ uploading your change for review.
</summary> </summary>
</histogram> </histogram>
<histogram name="Browser.PaintPreview.Capture.NumberOfFramesCaptured"
units="units" expires_after="2020-06-01">
<owner>ckitagawa@chromium.org</owner>
<owner>mahmoudi@chromium.org</owner>
<owner>vollick@chromium.org</owner>
<summary>
Records the number of frames captured by a paint preview if it succeeded.
</summary>
</histogram>
<histogram name="Browser.PaintPreview.Capture.Success" units="units"
expires_after="2020-06-01">
<owner>ckitagawa@chromium.org</owner>
<owner>mahmoudi@chromium.org</owner>
<owner>vollick@chromium.org</owner>
<summary>
Records a boolean indicating whether a capture attempt was successful.
</summary>
</histogram>
<histogram name="Browser.PaintPreview.Capture.TotalCaptureDuration" units="ms"
expires_after="2020-06-01">
<owner>ckitagawa@chromium.org</owner>
<owner>mahmoudi@chromium.org</owner>
<owner>vollick@chromium.org</owner>
<summary>
Records the total time spent capturing a paint preview of a page. This
includes capture and serialization of all frames and IPC time.
</summary>
</histogram>
<histogram name="Browser.Responsiveness.JankyIntervalsPerThirtySeconds" <histogram name="Browser.Responsiveness.JankyIntervalsPerThirtySeconds"
units="janks" expires_after="never"> units="janks" expires_after="never">
<!-- expires-never: guiding metric (internal: go/chrome-browser-guiding-metrics) --> <!-- expires-never: guiding metric (internal: go/chrome-browser-guiding-metrics) -->
...@@ -124742,6 +124773,48 @@ uploading your change for review. ...@@ -124742,6 +124773,48 @@ uploading your change for review.
</summary> </summary>
</histogram> </histogram>
<histogram name="Renderer.PaintPreview.Capture.MainFrameBlinkCaptureDuration"
units="ms" expires_after="2020-06-01">
<owner>ckitagawa@chromium.org</owner>
<owner>mahmoudi@chromium.org</owner>
<owner>vollick@chromium.org</owner>
<summary>
Records the number of milliseconds spent blocking Blink's main thread while
capturing the main frame.
</summary>
</histogram>
<histogram name="Renderer.PaintPreview.Capture.MainFrameSuccess" units="units"
expires_after="2020-06-01">
<owner>ckitagawa@chromium.org</owner>
<owner>mahmoudi@chromium.org</owner>
<owner>vollick@chromium.org</owner>
<summary>
Records a boolean indicating whether a capture for the main frame succeeded.
</summary>
</histogram>
<histogram name="Renderer.PaintPreview.Capture.SubframeBlinkCaptureDuration"
units="ms" expires_after="2020-06-01">
<owner>ckitagawa@chromium.org</owner>
<owner>mahmoudi@chromium.org</owner>
<owner>vollick@chromium.org</owner>
<summary>
Records the number of milliseconds spent blocking Blink's main thread while
capturing a subframe.
</summary>
</histogram>
<histogram name="Renderer.PaintPreview.Capture.SubframeSuccess" units="units"
expires_after="2020-06-01">
<owner>ckitagawa@chromium.org</owner>
<owner>mahmoudi@chromium.org</owner>
<owner>vollick@chromium.org</owner>
<summary>
Records a boolean indicating whether a capture for a subframe succeeded.
</summary>
</histogram>
<histogram name="Renderer.PixelIncreaseFromTransitions" units="units" <histogram name="Renderer.PixelIncreaseFromTransitions" units="units"
expires_after="2016-04-29"> expires_after="2016-04-29">
<obsolete> <obsolete>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment