summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authorjbroman <jbroman@chromium.org>2015-09-04 22:46:23 -0700
committerCommit bot <commit-bot@chromium.org>2015-09-05 05:47:18 +0000
commit0d30216f14e3f5620de722412d76cbdb7759ec42 (patch)
tree0367c1251d881193addb3e236fdf09c0766bf00a /cc
parent8d36b4e664b0b136fdb2edcddb78b5bec2e8444f (diff)
downloadchromium_src-0d30216f14e3f5620de722412d76cbdb7759ec42.zip
chromium_src-0d30216f14e3f5620de722412d76cbdb7759ec42.tar.gz
chromium_src-0d30216f14e3f5620de722412d76cbdb7759ec42.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}
Diffstat (limited to 'cc')
-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
6 files changed, 100 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 7288961..68066ac 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 f9d115a..7372d1d 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"
@@ -1022,13 +1023,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;