Commit 7468905c authored by akaba's avatar akaba Committed by Commit Bot

UMA for SurfaceManager

This CL adds the 3 following histograms:

1) logs the number of alive surfaces after each surface garbage
collection in Viz.

2) logs the number of temporary references after each surface garbage
collection in Viz.

3) logs the distance between a surface returned by SurfaceManager::GetLatestInFlightSurface
and the primary_surface_id passed in.

Bug: 866113
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel
Change-Id: I644c5005ba1a0997956a75083f8b25bd8a5f5abc
Reviewed-on: https://chromium-review.googlesource.com/1142591
Commit-Queue: Andre Kaba <akaba@google.com>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: default avatarSaman Sami <samans@chromium.org>
Reviewed-by: default avatarAlexei Svitkine <asvitkine@chromium.org>
Reviewed-by: default avatarFady Samuel <fsamuel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577340}
parent ed01860d
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include <algorithm>
#include "components/viz/common/surfaces/surface_id.h" #include "components/viz/common/surfaces/surface_id.h"
#include "components/viz/common/surfaces/surface_range.h" #include "components/viz/common/surfaces/surface_range.h"
...@@ -15,6 +17,21 @@ std::string SurfaceId::ToString() const { ...@@ -15,6 +17,21 @@ std::string SurfaceId::ToString() const {
local_surface_id_.ToString().c_str()); local_surface_id_.ToString().c_str());
} }
uint32_t SurfaceId::ManhattanDistanceTo(const SurfaceId& other) const {
DCHECK_EQ(frame_sink_id_, other.frame_sink_id());
DCHECK_EQ(local_surface_id_.embed_token(),
other.local_surface_id().embed_token());
return (std::max(local_surface_id_.parent_sequence_number(),
other.local_surface_id().parent_sequence_number()) -
std::min(local_surface_id_.parent_sequence_number(),
other.local_surface_id().parent_sequence_number())) +
(std::max(local_surface_id_.child_sequence_number(),
other.local_surface_id().child_sequence_number()) -
std::min(local_surface_id_.child_sequence_number(),
other.local_surface_id().child_sequence_number()));
}
std::ostream& operator<<(std::ostream& out, const SurfaceId& surface_id) { std::ostream& operator<<(std::ostream& out, const SurfaceId& surface_id) {
return out << surface_id.ToString(); return out << surface_id.ToString();
} }
......
...@@ -62,6 +62,10 @@ class VIZ_COMMON_EXPORT SurfaceId { ...@@ -62,6 +62,10 @@ class VIZ_COMMON_EXPORT SurfaceId {
// Returns whether this SurfaceId was generated after |other|. // Returns whether this SurfaceId was generated after |other|.
bool IsNewerThan(const SurfaceId& other) const; bool IsNewerThan(const SurfaceId& other) const;
// Compare this SurfaceId with |other| and returns the difference between the
// parent sequence numbers plus the difference between child sequence numbers.
uint32_t ManhattanDistanceTo(const SurfaceId& other) const;
bool operator==(const SurfaceId& other) const { bool operator==(const SurfaceId& other) const {
return frame_sink_id_ == other.frame_sink_id_ && return frame_sink_id_ == other.frame_sink_id_ &&
local_surface_id_ == other.local_surface_id_; local_surface_id_ == other.local_surface_id_;
......
...@@ -48,6 +48,9 @@ const char kUmaNoActiveFrame[] = ...@@ -48,6 +48,9 @@ const char kUmaNoActiveFrame[] =
"Compositing.SurfaceAggregator.SurfaceDrawQuad.NoActiveFrame"; "Compositing.SurfaceAggregator.SurfaceDrawQuad.NoActiveFrame";
const char kUmaUsingFallbackSurface[] = const char kUmaUsingFallbackSurface[] =
"Compositing.SurfaceAggregator.SurfaceDrawQuad.UsingFallbackSurface"; "Compositing.SurfaceAggregator.SurfaceDrawQuad.UsingFallbackSurface";
const char kUmaManhattanDistanceToPrimary[] =
"Compositing.SurfaceAggregator.LatestInFlightSurface."
"ManhattanDistanceToPrimary";
void MoveMatchingRequests( void MoveMatchingRequests(
RenderPassId render_pass_id, RenderPassId render_pass_id,
...@@ -217,25 +220,33 @@ void SurfaceAggregator::HandleSurfaceQuad( ...@@ -217,25 +220,33 @@ void SurfaceAggregator::HandleSurfaceQuad(
dest_pass); dest_pass);
return; return;
} }
Surface* latest_surface = manager_->GetLatestInFlightSurface(
Surface* fallback_surface = manager_->GetLatestInFlightSurface(
primary_surface_id, *surface_quad->surface_range.start()); primary_surface_id, *surface_quad->surface_range.start());
if (latest_surface &&
primary_surface_id.frame_sink_id() ==
latest_surface->surface_id().frame_sink_id() &&
primary_surface_id.local_surface_id().embed_token() ==
latest_surface->surface_id().local_surface_id().embed_token()) {
UMA_HISTOGRAM_COUNTS_100(
kUmaManhattanDistanceToPrimary,
latest_surface->surface_id().ManhattanDistanceTo(primary_surface_id));
}
// If the fallback is specified and missing then that's an error. Report the // If the fallback is specified and missing then that's an error. Report the
// error to console, and log the UMA. // error to console, and log the UMA.
if (!fallback_surface || !fallback_surface->HasActiveFrame()) { if (!latest_surface || !latest_surface->HasActiveFrame()) {
ReportMissingFallbackSurface(*surface_quad->surface_range.start(), ReportMissingFallbackSurface(*surface_quad->surface_range.start(),
fallback_surface); latest_surface);
EmitDefaultBackgroundColorQuad(surface_quad, target_transform, clip_rect, EmitDefaultBackgroundColorQuad(surface_quad, target_transform, clip_rect,
dest_pass); dest_pass);
return; return;
} }
if (!surface_quad->stretch_content_to_fill_bounds) { if (!surface_quad->stretch_content_to_fill_bounds) {
const CompositorFrame& fallback_frame = fallback_surface->GetActiveFrame(); const CompositorFrame& fallback_frame = latest_surface->GetActiveFrame();
gfx::Rect fallback_rect( gfx::Rect fallback_rect(latest_surface->GetActiveFrame().size_in_pixels());
fallback_surface->GetActiveFrame().size_in_pixels());
float scale_ratio = float scale_ratio =
parent_device_scale_factor / fallback_frame.device_scale_factor(); parent_device_scale_factor / fallback_frame.device_scale_factor();
...@@ -251,7 +262,7 @@ void SurfaceAggregator::HandleSurfaceQuad( ...@@ -251,7 +262,7 @@ void SurfaceAggregator::HandleSurfaceQuad(
++uma_stats_.using_fallback_surface; ++uma_stats_.using_fallback_surface;
EmitSurfaceContent(fallback_surface, parent_device_scale_factor, EmitSurfaceContent(latest_surface, parent_device_scale_factor,
surface_quad->shared_quad_state, surface_quad->rect, surface_quad->shared_quad_state, surface_quad->rect,
surface_quad->visible_rect, target_transform, clip_rect, surface_quad->visible_rect, target_transform, clip_rect,
surface_quad->stretch_content_to_fill_bounds, dest_pass, surface_quad->stretch_content_to_fill_bounds, dest_pass,
......
...@@ -28,6 +28,11 @@ ...@@ -28,6 +28,11 @@
namespace viz { namespace viz {
namespace { namespace {
const char kUmaAliveSurfaces[] = "Compositing.SurfaceManager.AliveSurfaces";
const char kUmaTemporarySurfaces[] =
"Compositing.SurfaceManager.TemporarySurfaces";
constexpr base::TimeDelta kExpireInterval = base::TimeDelta::FromSeconds(10); constexpr base::TimeDelta kExpireInterval = base::TimeDelta::FromSeconds(10);
const char kUmaRemovedTemporaryReference[] = const char kUmaRemovedTemporaryReference[] =
...@@ -228,6 +233,13 @@ void SurfaceManager::GarbageCollectSurfaces() { ...@@ -228,6 +233,13 @@ void SurfaceManager::GarbageCollectSurfaces() {
SurfaceIdSet reachable_surfaces = GetLiveSurfacesForReferences(); SurfaceIdSet reachable_surfaces = GetLiveSurfacesForReferences();
// Log the number of reachable surfaces after a garbage collection.
UMA_HISTOGRAM_CUSTOM_COUNTS(kUmaAliveSurfaces, reachable_surfaces.size(), 1,
200, 50);
// Log the number of temporary references after a garbage collection.
UMA_HISTOGRAM_CUSTOM_COUNTS(kUmaTemporarySurfaces,
temporary_references_.size(), 1, 200, 50);
std::vector<SurfaceId> surfaces_to_delete; std::vector<SurfaceId> surfaces_to_delete;
// Delete all destroyed and unreachable surfaces. // Delete all destroyed and unreachable surfaces.
......
...@@ -12976,6 +12976,17 @@ uploading your change for review. ...@@ -12976,6 +12976,17 @@ uploading your change for review.
</summary> </summary>
</histogram> </histogram>
<histogram
name="Compositing.SurfaceAggregator.LatestInFlightSurface.
ManhattanDistanceToPrimary" units="surfaces">
<owner>akaba@chromium.org</owner>
<owner>fsamuel@chromium.org</owner>
<summary>
The distance between the latest inflight surface and the primary surface.
This is logged for each call to HandleSurfaceQuad().
</summary>
</histogram>
<histogram name="Compositing.SurfaceAggregator.SurfaceDrawQuad.MissingSurface" <histogram name="Compositing.SurfaceAggregator.SurfaceDrawQuad.MissingSurface"
units="quads"> units="quads">
<owner>kylechar@chromium.org</owner> <owner>kylechar@chromium.org</owner>
...@@ -13042,6 +13053,14 @@ uploading your change for review. ...@@ -13042,6 +13053,14 @@ uploading your change for review.
</summary> </summary>
</histogram> </histogram>
<histogram name="Compositing.SurfaceManager.AliveSurfaces" units="surfaces">
<owner>akaba@chromium.org</owner>
<owner>fsamuel@chromium.org</owner>
<summary>
Tracks the number of alive surfaces after each garbage collection operation.
</summary>
</histogram>
<histogram name="Compositing.SurfaceManager.NumOldTemporaryReferences"> <histogram name="Compositing.SurfaceManager.NumOldTemporaryReferences">
<obsolete> <obsolete>
Deprecated 2018/01/24. Deprecated 2018/01/24.
...@@ -13059,6 +13078,16 @@ uploading your change for review. ...@@ -13059,6 +13078,16 @@ uploading your change for review.
<summary>Tracks the reason for removing a temporary reference.</summary> <summary>Tracks the reason for removing a temporary reference.</summary>
</histogram> </histogram>
<histogram name="Compositing.SurfaceManager.TemporarySurfaces"
units="references">
<owner>akaba@chromium.org</owner>
<owner>fsamuel@chromium.org</owner>
<summary>
Tracks the number of temporary references after each garbage collection
operation.
</summary>
</histogram>
<histogram name="Conflicts.ConfirmedBadModules" units="modules"> <histogram name="Conflicts.ConfirmedBadModules" units="modules">
<owner>chrisha@chromium.org</owner> <owner>chrisha@chromium.org</owner>
<summary> <summary>
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