Commit 4749ce29 authored by Vladimir Levin's avatar Vladimir Levin Committed by Commit Bot

cc/metrics: Fix a test-only assert failure in UMA.

This patch address an UMA assert failure. It happens because we record
metrics with a null client in most of the tests (the metrics name is
never set). However, some tests that verify UMA buckets do set the name.
In those cases, UMA assert fails since the we are using a different uma
name in the same process.

The fix is to only record UMAs if we have a client name set. Ideally
we would fix this at the test level instead, so I left a TODO.

R=khushalsagar@chromium.org, ericrk@chromium.org

Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel
Change-Id: Ida6d605963d123ce683b1c1b8b9814904d17ff45
Reviewed-on: https://chromium-review.googlesource.com/764583Reviewed-by: default avatarEric Karl <ericrk@chromium.org>
Commit-Queue: vmpstr <vmpstr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#516069}
parent 48990226
......@@ -499,10 +499,16 @@ GpuImageDecodeCache::~GpuImageDecodeCache() {
// Unregister this component with memory_coordinator::ClientRegistry.
base::MemoryCoordinatorClientRegistry::GetInstance()->Unregister(this);
UMA_HISTOGRAM_CUSTOM_COUNTS(
base::StringPrintf("Compositing.%s.CachedImagesCount.Gpu",
GetClientNameForMetrics()),
lifetime_max_items_in_cache_, 1, 1000, 20);
// TODO(vmpstr): If we don't have a client name, it may cause problems in
// unittests, since most tests don't set the name but some do. The UMA system
// expects the name to be always the same. This assertion is violated in the
// tests that do set the name.
if (GetClientNameForMetrics()) {
UMA_HISTOGRAM_CUSTOM_COUNTS(
base::StringPrintf("Compositing.%s.CachedImagesCount.Gpu",
GetClientNameForMetrics()),
lifetime_max_items_in_cache_, 1, 1000, 20);
}
}
ImageDecodeCache::TaskResult GpuImageDecodeCache::GetTaskForImageAndRef(
......
......@@ -221,10 +221,16 @@ SoftwareImageDecodeCache::~SoftwareImageDecodeCache() {
// Unregister this component with memory_coordinator::ClientRegistry.
base::MemoryCoordinatorClientRegistry::GetInstance()->Unregister(this);
UMA_HISTOGRAM_CUSTOM_COUNTS(
base::StringPrintf("Compositing.%s.CachedImagesCount.Software",
GetClientNameForMetrics()),
lifetime_max_items_in_cache_, 1, 1000, 20);
// TODO(vmpstr): If we don't have a client name, it may cause problems in
// unittests, since most tests don't set the name but some do. The UMA system
// expects the name to be always the same. This assertion is violated in the
// tests that do set the name.
if (GetClientNameForMetrics()) {
UMA_HISTOGRAM_CUSTOM_COUNTS(
base::StringPrintf("Compositing.%s.CachedImagesCount.Software",
GetClientNameForMetrics()),
lifetime_max_items_in_cache_, 1, 1000, 20);
}
}
ImageDecodeCache::TaskResult SoftwareImageDecodeCache::GetTaskForImageAndRef(
......
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