summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Roman <jbroman@chromium.org>2015-09-08 17:40:10 -0400
committerJeremy Roman <jbroman@chromium.org>2015-09-08 21:41:32 +0000
commit83a44a77943a21f01abf6213765aee34de392b71 (patch)
tree9341131c3d489d335453a910d5e9731e849688d5
parentebe85449f277b36d6ebda7d41a62b1172d1758d1 (diff)
downloadchromium_src-83a44a77943a21f01abf6213765aee34de392b71.zip
chromium_src-83a44a77943a21f01abf6213765aee34de392b71.tar.gz
chromium_src-83a44a77943a21f01abf6213765aee34de392b71.tar.bz2
Track cc histograms using a global "client name" variable.
BUG=526192 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1321013004 Cr-Commit-Position: refs/heads/master@{#347565} (cherry picked from commit 0d30216f14e3f5620de722412d76cbdb7759ec42) TBR=chrishtr@chromium.org,wkorman@chromium.org Review URL: https://codereview.chromium.org/1321913005 . Cr-Commit-Position: refs/branch-heads/2490@{#189} Cr-Branched-From: 7790a3535f2a81a03685eca31a32cf69ae0c114f-refs/heads/master@{#344925}
-rw-r--r--cc/base/histograms.cc39
-rw-r--r--cc/base/histograms.h59
-rw-r--r--cc/playback/display_list_recording_source.cc4
-rw-r--r--cc/playback/picture_pile.cc4
-rw-r--r--cc/tiles/tile_manager.cc4
-rw-r--r--cc/trees/layer_tree_host_impl.cc20
-rw-r--r--content/browser/compositor/gpu_process_transport_factory.cc2
-rw-r--r--content/renderer/render_thread_impl.cc2
-rw-r--r--tools/metrics/histograms/histograms.xml155
9 files changed, 259 insertions, 30 deletions
diff --git a/cc/base/histograms.cc b/cc/base/histograms.cc
index 9fe1515..ba6f4f6 100644
--- a/cc/base/histograms.cc
+++ b/cc/base/histograms.cc
@@ -6,12 +6,51 @@
#include <algorithm>
#include <cmath>
+#include <cstring>
#include <limits>
+#include "base/lazy_instance.h"
+#include "base/logging.h"
#include "base/numerics/safe_conversions.h"
+#include "base/synchronization/lock.h"
namespace cc {
+// Global data tracking the client name that was set.
+// Both of these variables are protected by the lock.
+static base::LazyInstance<base::Lock>::Leaky g_client_name_lock =
+ LAZY_INSTANCE_INITIALIZER;
+static const char* g_client_name = nullptr;
+static bool g_multiple_client_names_set = false;
+
+void SetClientNameForMetrics(const char* client_name) {
+ base::AutoLock auto_lock(g_client_name_lock.Get());
+
+ // Only warn once.
+ if (g_multiple_client_names_set)
+ return;
+
+ // If a different name is set, return nullptr from now on and log a warning.
+ const char* old_client_name = g_client_name;
+ if (old_client_name && strcmp(old_client_name, client_name)) {
+ g_client_name = nullptr;
+ g_multiple_client_names_set = true;
+ LOG(WARNING) << "Started multiple compositor clients (" << old_client_name
+ << ", " << client_name
+ << ") in one process. Some metrics will be disabled.";
+ return;
+ }
+
+ // If the client name is being set for the first time, store it.
+ if (!old_client_name)
+ g_client_name = client_name;
+}
+
+const char* GetClientNameForMetrics() {
+ base::AutoLock auto_lock(g_client_name_lock.Get());
+ return g_client_name;
+}
+
// Minimum elapsed time of 1us to limit weighting of fast calls.
static const int64 kMinimumTimeMicroseconds = 1;
diff --git a/cc/base/histograms.h b/cc/base/histograms.h
index 0c8a2bc..542ae5d 100644
--- a/cc/base/histograms.h
+++ b/cc/base/histograms.h
@@ -9,38 +9,63 @@
#include "base/metrics/histogram_base.h"
#include "base/metrics/histogram_macros.h"
#include "base/numerics/safe_math.h"
+#include "base/strings/stringprintf.h"
#include "base/time/time.h"
#include "base/timer/elapsed_timer.h"
#include "cc/base/cc_export.h"
namespace cc {
+// Supplies a client name to be inserted into histogram names.
+// These are known so far: Renderer, Browser
+//
+// We currently assume that there is only one distinct client per process.
+// Not thread-safe. If called multiple times, warns and skips metrics.
+CC_EXPORT void SetClientNameForMetrics(const char* client_name);
+
+// Returns the client name, for use by applicable cc metrics code.
+// May return null, in which case no clients, or at least two clients, set the
+// client name, and these metrics should be omitted.
+//
+// This method guarantees that it will never return two distinct non-null
+// values over the lifetime of the process.
+const char* GetClientNameForMetrics();
+
// Emits UMA histogram trackers for time spent as well as area (in pixels)
// processed per unit time. Time is measured in microseconds, and work in
-// pixels per millisecond.
+// pixels per millisecond. Histogram name should include a %s to grab the client
+// name.
//
// Usage:
// // Outside of a method, perhaps in a namespace.
-// DEFINE_SCOPED_UMA_HISTOGRAM_AREA_TIMER(ScopedReticulateSplinesTimer,
-// "ReticulateSplinesUs",
-// "ReticulateSplinesPixelsPerMs");
+// DEFINE_SCOPED_UMA_HISTOGRAM_AREA_TIMER(
+// ScopedReticulateSplinesTimer,
+// "Compositing.%s.ReticulateSplinesUs",
+// "Compositing.%s.ReticulateSplinesPixelsPerMs");
//
// // Inside a method.
// ScopedReticulateSplinesTimer timer;
// timer.AddArea(some_rect.size().GetArea());
-#define DEFINE_SCOPED_UMA_HISTOGRAM_AREA_TIMER(class_name, time_histogram, \
- area_histogram) \
- class class_name : public ::cc::ScopedUMAHistogramAreaTimerBase { \
- public: \
- ~class_name(); \
- }; \
- class_name::~class_name() { \
- Sample time_sample; \
- Sample area_sample; \
- if (GetHistogramValues(&time_sample, &area_sample)) { \
- UMA_HISTOGRAM_COUNTS(time_histogram, time_sample); \
- UMA_HISTOGRAM_COUNTS(area_histogram, area_sample); \
- } \
+//
+#define DEFINE_SCOPED_UMA_HISTOGRAM_AREA_TIMER(class_name, time_histogram, \
+ area_histogram) \
+ class class_name : public ::cc::ScopedUMAHistogramAreaTimerBase { \
+ public: \
+ ~class_name(); \
+ }; \
+ class_name::~class_name() { \
+ Sample time_sample; \
+ Sample area_sample; \
+ const char* client_name = ::cc::GetClientNameForMetrics(); \
+ if (client_name && GetHistogramValues(&time_sample, &area_sample)) { \
+ /* GetClientNameForMetrics only returns one non-null value over */ \
+ /* the lifetime of the process, so these histogram names are */ \
+ /* runtime constant. */ \
+ UMA_HISTOGRAM_COUNTS(base::StringPrintf(time_histogram, client_name), \
+ time_sample); \
+ UMA_HISTOGRAM_COUNTS(base::StringPrintf(area_histogram, client_name), \
+ area_sample); \
+ } \
}
class CC_EXPORT ScopedUMAHistogramAreaTimerBase {
diff --git a/cc/playback/display_list_recording_source.cc b/cc/playback/display_list_recording_source.cc
index c06fcfa..6bd14ff 100644
--- a/cc/playback/display_list_recording_source.cc
+++ b/cc/playback/display_list_recording_source.cc
@@ -34,8 +34,8 @@ const bool kDefaultClearCanvasSetting = true;
DEFINE_SCOPED_UMA_HISTOGRAM_AREA_TIMER(
ScopedDisplayListRecordingSourceUpdateTimer,
- "Compositing.DisplayListRecordingSource.UpdateUs",
- "Compositing.DisplayListRecordingSource.UpdateInvalidatedAreaPerMs");
+ "Compositing.%s.DisplayListRecordingSource.UpdateUs",
+ "Compositing.%s.DisplayListRecordingSource.UpdateInvalidatedAreaPerMs");
} // namespace
diff --git a/cc/playback/picture_pile.cc b/cc/playback/picture_pile.cc
index bafa0ed..bdb4700 100644
--- a/cc/playback/picture_pile.cc
+++ b/cc/playback/picture_pile.cc
@@ -149,8 +149,8 @@ const bool kDefaultClearCanvasSetting = true;
DEFINE_SCOPED_UMA_HISTOGRAM_AREA_TIMER(
ScopedPicturePileUpdateTimer,
- "Compositing.PicturePile.UpdateUs",
- "Compositing.PicturePile.UpdateInvalidatedAreaPerMs");
+ "Compositing.%s.PicturePile.UpdateUs",
+ "Compositing.%s.PicturePile.UpdateInvalidatedAreaPerMs");
} // namespace
diff --git a/cc/tiles/tile_manager.cc b/cc/tiles/tile_manager.cc
index 5078714..29dbd92 100644
--- a/cc/tiles/tile_manager.cc
+++ b/cc/tiles/tile_manager.cc
@@ -33,8 +33,8 @@ const bool kUseColorEstimator = true;
DEFINE_SCOPED_UMA_HISTOGRAM_AREA_TIMER(
ScopedRasterTaskTimer,
- "Compositing.RasterTask.RasterUs",
- "Compositing.RasterTask.RasterPixelsPerMs");
+ "Compositing.%s.RasterTask.RasterUs",
+ "Compositing.%s.RasterTask.RasterPixelsPerMs");
class RasterTaskImpl : public RasterTask {
public:
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index a3a9b2c..7fe2181 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -23,6 +23,7 @@
#include "cc/animation/scroll_offset_animation_curve.h"
#include "cc/animation/scrollbar_animation_controller.h"
#include "cc/animation/timing_function.h"
+#include "cc/base/histograms.h"
#include "cc/base/math_util.h"
#include "cc/debug/benchmark_instrumentation.h"
#include "cc/debug/debug_rect_history.h"
@@ -1034,13 +1035,18 @@ DrawResult LayerTreeHostImpl::PrepareToDraw(FrameData* frame) {
"Compositing.NumActiveLayers",
base::saturated_cast<int>(active_tree_->NumLayers()), 1, 400, 20);
- size_t total_picture_memory = 0;
- for (const PictureLayerImpl* layer : active_tree()->picture_layers())
- total_picture_memory += layer->GetRasterSource()->GetPictureMemoryUsage();
- if (total_picture_memory != 0) {
- UMA_HISTOGRAM_COUNTS(
- "Compositing.PictureMemoryUsageKb",
- base::saturated_cast<int>(total_picture_memory / 1024));
+ if (const char* client_name = GetClientNameForMetrics()) {
+ size_t total_picture_memory = 0;
+ for (const PictureLayerImpl* layer : active_tree()->picture_layers())
+ total_picture_memory += layer->GetRasterSource()->GetPictureMemoryUsage();
+ if (total_picture_memory != 0) {
+ // GetClientNameForMetrics only returns one non-null value over the
+ // lifetime of the process, so this histogram name is runtime constant.
+ UMA_HISTOGRAM_COUNTS(
+ base::StringPrintf("Compositing.%s.PictureMemoryUsageKb",
+ client_name),
+ base::saturated_cast<int>(total_picture_memory / 1024));
+ }
}
bool update_lcd_text = false;
diff --git a/content/browser/compositor/gpu_process_transport_factory.cc b/content/browser/compositor/gpu_process_transport_factory.cc
index 4c0b363..7bfccf7 100644
--- a/content/browser/compositor/gpu_process_transport_factory.cc
+++ b/content/browser/compositor/gpu_process_transport_factory.cc
@@ -14,6 +14,7 @@
#include "base/thread_task_runner_handle.h"
#include "base/threading/simple_thread.h"
#include "base/threading/thread.h"
+#include "cc/base/histograms.h"
#include "cc/output/compositor_frame.h"
#include "cc/output/output_surface.h"
#include "cc/raster/task_graph_runner.h"
@@ -106,6 +107,7 @@ GpuProcessTransportFactory::GpuProcessTransportFactory()
task_graph_runner_(new cc::TaskGraphRunner),
callback_factory_(this) {
ui::Layer::InitializeUILayerSettings();
+ cc::SetClientNameForMetrics("Browser");
if (UseSurfacesEnabled())
surface_manager_ = make_scoped_ptr(new cc::SurfaceManager);
diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc
index 0a146ea..b5a13c1 100644
--- a/content/renderer/render_thread_impl.cc
+++ b/content/renderer/render_thread_impl.cc
@@ -32,6 +32,7 @@
#include "base/trace_event/memory_dump_manager.h"
#include "base/trace_event/trace_event.h"
#include "base/values.h"
+#include "cc/base/histograms.h"
#include "cc/base/switches.h"
#include "cc/blink/web_external_bitmap_impl.h"
#include "cc/blink/web_layer_impl.h"
@@ -647,6 +648,7 @@ void RenderThreadImpl::Init() {
if (command_line.HasSwitch(switches::kEnableCompositorAnimationTimelines))
layer_settings.use_compositor_animation_timelines = true;
cc_blink::WebLayerImpl::SetLayerSettings(layer_settings);
+ cc::SetClientNameForMetrics("Renderer");
is_threaded_animation_enabled_ =
!command_line.HasSwitch(cc::switches::kDisableThreadedAnimation);
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml
index bad91ac..e345bd3 100644
--- a/tools/metrics/histograms/histograms.xml
+++ b/tools/metrics/histograms/histograms.xml
@@ -4152,6 +4152,69 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
<summary>Number of tries before successful ping. 99 means giving up.</summary>
</histogram>
+<histogram
+ name="Compositing.Browser.DisplayListRecordingSource.UpdateInvalidatedAreaPerMs"
+ units="pixels/ms">
+ <owner>paint-dev@chromium.org</owner>
+ <summary>
+ Area of invalidated content, in pixels, divided by update (i.e. record), in
+ milliseconds. Recorded when display list recording source is updated (in a
+ browser process).
+ </summary>
+</histogram>
+
+<histogram name="Compositing.Browser.DisplayListRecordingSource.UpdateUs"
+ units="microseconds">
+ <owner>paint-dev@chromium.org</owner>
+ <summary>
+ Time spent updating (i.e. recording) a display list, in microseconds.
+ Recorded when display list is updated (in a browser process).
+ </summary>
+</histogram>
+
+<histogram name="Compositing.Browser.PictureMemoryUsageKb" units="KB">
+ <owner>paint-dev@chromium.org</owner>
+ <summary>
+ Total estimated memory used by SkPictures in the layer tree, in kilobytes.
+ Recorded once per frame, before the frame is drawn (in a browser process).
+ </summary>
+</histogram>
+
+<histogram name="Compositing.Browser.PicturePile.UpdateInvalidatedAreaPerMs"
+ units="pixels/ms">
+ <owner>paint-dev@chromium.org</owner>
+ <summary>
+ Area of invalidated content, in pixels, divided by update (i.e. record), in
+ milliseconds. Recorded when picture pile is updated (in a browser process).
+ </summary>
+</histogram>
+
+<histogram name="Compositing.Browser.PicturePile.UpdateUs" units="microseconds">
+ <owner>paint-dev@chromium.org</owner>
+ <summary>
+ Time spent updating (i.e. recording) a picture pile, in microseconds.
+ Recorded when picture pile is updated (in a browser process).
+ </summary>
+</histogram>
+
+<histogram name="Compositing.Browser.RasterTask.RasterPixelsPerMs"
+ units="pixels/ms">
+ <owner>paint-dev@chromium.org</owner>
+ <summary>
+ Rasterized area, in pixels, divided by rasterization time, in milliseconds,
+ of a compositor rasterization task. Recorded after the task finishes (in a
+ browser process).
+ </summary>
+</histogram>
+
+<histogram name="Compositing.Browser.RasterTask.RasterUs" units="microseconds">
+ <owner>paint-dev@chromium.org</owner>
+ <summary>
+ Time spent completing a compositor rasterization task, in microseconds.
+ Recorded after the task finishes (in a browser process).
+ </summary>
+</histogram>
+
<histogram name="Compositing.CopyFromSurfaceTime" units="ms">
<owner>Please list the metric's owners. Add more owner tags as needed.</owner>
<summary>
@@ -4170,6 +4233,10 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
<histogram
name="Compositing.DisplayListRecordingSource.UpdateInvalidatedAreaPerMs"
units="pixels/ms">
+ <obsolete>
+ Deprecated 09/2015, replaced by similar metrics under Compositing.Renderer
+ and Compositing.Browser, depending on which process it occurs in.
+ </obsolete>
<owner>paint-dev@chromium.org</owner>
<summary>
Area of invalidated content, in pixels, divided by update (i.e. record), in
@@ -4179,6 +4246,10 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
<histogram name="Compositing.DisplayListRecordingSource.UpdateUs"
units="microseconds">
+ <obsolete>
+ Deprecated 09/2015, replaced by similar metrics under Compositing.Renderer
+ and Compositing.Browser, depending on which process it occurs in.
+ </obsolete>
<owner>paint-dev@chromium.org</owner>
<summary>
Time spent updating (i.e. recording) a display list, in microseconds.
@@ -4195,6 +4266,10 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</histogram>
<histogram name="Compositing.PictureMemoryUsageKb" units="KB">
+ <obsolete>
+ Deprecated 09/2015, replaced by similar metrics under Compositing.Renderer
+ and Compositing.Browser, depending on which process it occurs in.
+ </obsolete>
<owner>paint-dev@chromium.org</owner>
<summary>
Total estimated memory used by SkPictures in the layer tree, in kilobytes.
@@ -4204,6 +4279,10 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
<histogram name="Compositing.PicturePile.UpdateInvalidatedAreaPerMs"
units="pixels/ms">
+ <obsolete>
+ Deprecated 09/2015, replaced by similar metrics under Compositing.Renderer
+ and Compositing.Browser, depending on which process it occurs in.
+ </obsolete>
<owner>paint-dev@chromium.org</owner>
<summary>
Area of invalidated content, in pixels, divided by update (i.e. record), in
@@ -4212,6 +4291,10 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</histogram>
<histogram name="Compositing.PicturePile.UpdateUs" units="microseconds">
+ <obsolete>
+ Deprecated 09/2015, replaced by similar metrics under Compositing.Renderer
+ and Compositing.Browser, depending on which process it occurs in.
+ </obsolete>
<owner>paint-dev@chromium.org</owner>
<summary>
Time spent updating (i.e. recording) a picture pile, in microseconds.
@@ -4220,6 +4303,10 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</histogram>
<histogram name="Compositing.RasterTask.RasterPixelsPerMs" units="pixels/ms">
+ <obsolete>
+ Deprecated 09/2015, replaced by similar metrics under Compositing.Renderer
+ and Compositing.Browser, depending on which process it occurs in.
+ </obsolete>
<owner>paint-dev@chromium.org</owner>
<summary>
Rasterized area, in pixels, divided by rasterization time, in milliseconds,
@@ -4228,6 +4315,10 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</histogram>
<histogram name="Compositing.RasterTask.RasterUs" units="microseconds">
+ <obsolete>
+ Deprecated 09/2015, replaced by similar metrics under Compositing.Renderer
+ and Compositing.Browser, depending on which process it occurs in.
+ </obsolete>
<owner>paint-dev@chromium.org</owner>
<summary>
Time spent completing a compositor rasterization task, in microseconds.
@@ -4235,6 +4326,70 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</summary>
</histogram>
+<histogram
+ name="Compositing.Renderer.DisplayListRecordingSource.UpdateInvalidatedAreaPerMs"
+ units="pixels/ms">
+ <owner>paint-dev@chromium.org</owner>
+ <summary>
+ Area of invalidated content, in pixels, divided by update (i.e. record), in
+ milliseconds. Recorded when display list recording source is updated (in a
+ renderer process).
+ </summary>
+</histogram>
+
+<histogram name="Compositing.Renderer.DisplayListRecordingSource.UpdateUs"
+ units="microseconds">
+ <owner>paint-dev@chromium.org</owner>
+ <summary>
+ Time spent updating (i.e. recording) a display list, in microseconds.
+ Recorded when display list is updated (in a renderer process).
+ </summary>
+</histogram>
+
+<histogram name="Compositing.Renderer.PictureMemoryUsageKb" units="KB">
+ <owner>paint-dev@chromium.org</owner>
+ <summary>
+ Total estimated memory used by SkPictures in the layer tree, in kilobytes.
+ Recorded once per frame, before the frame is drawn (in a renderer process).
+ </summary>
+</histogram>
+
+<histogram name="Compositing.Renderer.PicturePile.UpdateInvalidatedAreaPerMs"
+ units="pixels/ms">
+ <owner>paint-dev@chromium.org</owner>
+ <summary>
+ Area of invalidated content, in pixels, divided by update (i.e. record), in
+ milliseconds. Recorded when picture pile is updated (in a renderer process).
+ </summary>
+</histogram>
+
+<histogram name="Compositing.Renderer.PicturePile.UpdateUs"
+ units="microseconds">
+ <owner>paint-dev@chromium.org</owner>
+ <summary>
+ Time spent updating (i.e. recording) a picture pile, in microseconds.
+ Recorded when picture pile is updated (in a renderer process).
+ </summary>
+</histogram>
+
+<histogram name="Compositing.Renderer.RasterTask.RasterPixelsPerMs"
+ units="pixels/ms">
+ <owner>paint-dev@chromium.org</owner>
+ <summary>
+ Rasterized area, in pixels, divided by rasterization time, in milliseconds,
+ of a compositor rasterization task. Recorded after the task finishes (in a
+ renderer process).
+ </summary>
+</histogram>
+
+<histogram name="Compositing.Renderer.RasterTask.RasterUs" units="microseconds">
+ <owner>paint-dev@chromium.org</owner>
+ <summary>
+ Time spent completing a compositor rasterization task, in microseconds.
+ Recorded after the task finishes (in a renderer process).
+ </summary>
+</histogram>
+
<histogram name="Compositing.RenderPass.AppendQuadData.NumIncompleteTiles">
<owner>weiliangc@chromium.org.</owner>
<summary>