Commit ec8eedf8 authored by Adrienne Walker's avatar Adrienne Walker Committed by Commit Bot

Add GpuMemory UMAs and UKMs

Previously CommandBuffer sizes accurately captured the amount of
gpu memory used by Chrome.  However, recent changes like OOPR and shared
images have spread this memory over multiple categories.

Add a single UMA/UKM to report this memory so that we can accurately
track it in the wild.

Bug: 960499
Change-Id: I9aea6bd93dffc2d226f2e3f5c72696ad37942960
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1611862
Commit-Queue: enne <enne@chromium.org>
Reviewed-by: default avatarRobert Kaplow (slow) <rkaplow@chromium.org>
Reviewed-by: default avatarEric Karl <ericrk@chromium.org>
Reviewed-by: default avatarNik Bhagat <nikunjb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#664382}
parent ce57afbf
......@@ -390,6 +390,35 @@ void EmitProcessUmaAndUkm(const GlobalMemoryDump::ProcessDump& pmd,
#endif
}
void EmitSummedGpuMemory(const GlobalMemoryDump::ProcessDump& pmd,
Memory_Experimental* builder,
bool record_uma) {
// Combine several categories together to sum up Chrome-reported gpu memory.
static const char* gpu_categories[] = {
"gpu/gl",
"gpu/shared-images",
"skia/gpu_resources",
};
Metric synthetic_metric = {nullptr,
"GpuMemory",
kLargeMetric,
kEffectiveSize,
EmitTo::kSizeInUkmAndUma,
&Memory_Experimental::SetGpuMemory};
uint64_t total = 0;
for (size_t i = 0; i < base::size(gpu_categories); ++i) {
total +=
pmd.GetMetric(gpu_categories[i], synthetic_metric.metric).value_or(0);
}
// Always use "Gpu" as the process name for this even for the in process
// command buffer case.
EmitProcessUkm(synthetic_metric, total, builder);
if (record_uma)
EmitProcessUma("Gpu", synthetic_metric, total);
}
void EmitBrowserMemoryMetrics(const GlobalMemoryDump::ProcessDump& pmd,
ukm::SourceId ukm_source_id,
ukm::UkmRecorder* ukm_recorder,
......@@ -399,6 +428,7 @@ void EmitBrowserMemoryMetrics(const GlobalMemoryDump::ProcessDump& pmd,
builder.SetProcessType(static_cast<int64_t>(
memory_instrumentation::mojom::ProcessType::BROWSER));
EmitProcessUmaAndUkm(pmd, "Browser", uptime, record_uma, &builder);
EmitSummedGpuMemory(pmd, &builder, record_uma);
builder.Record(ukm_recorder);
}
......@@ -440,7 +470,7 @@ void EmitGpuMemoryMetrics(const GlobalMemoryDump::ProcessDump& pmd,
builder.SetProcessType(
static_cast<int64_t>(memory_instrumentation::mojom::ProcessType::GPU));
EmitProcessUmaAndUkm(pmd, "Gpu", uptime, record_uma, &builder);
EmitSummedGpuMemory(pmd, &builder, record_uma);
builder.Record(ukm_recorder);
}
......
......@@ -128,6 +128,12 @@ OSMemDumpPtr GetFakeOSMemDump(uint32_t resident_set_kb,
);
}
constexpr uint64_t kGpuSharedImagesSizeMB = 32;
constexpr uint64_t kGpuSkiaGpuResourcesMB = 87;
constexpr uint64_t kGpuCommandBufferMB = 240;
constexpr uint64_t kGpuTotalMemory =
kGpuCommandBufferMB + kGpuSharedImagesSizeMB + kGpuSkiaGpuResourcesMB;
void PopulateBrowserMetrics(GlobalMemoryDumpPtr& global_dump,
MetricMap& metrics_mb) {
ProcessMemoryDumpPtr pmd(
......@@ -135,6 +141,14 @@ void PopulateBrowserMetrics(GlobalMemoryDumpPtr& global_dump,
pmd->process_type = ProcessType::BROWSER;
SetAllocatorDumpMetric(pmd, "malloc", "effective_size",
metrics_mb["Malloc"] * 1024 * 1024);
// These three categories are required for total gpu memory, but do not
// have a UKM value set for them, so don't appear in metrics_mb.
SetAllocatorDumpMetric(pmd, "gpu/gl", "effective_size",
kGpuCommandBufferMB * 1024 * 1024);
SetAllocatorDumpMetric(pmd, "gpu/shared-images", "effective_size",
kGpuSharedImagesSizeMB * 1024 * 1024);
SetAllocatorDumpMetric(pmd, "skia/gpu_resources", "effective_size",
kGpuSkiaGpuResourcesMB * 1024 * 1024);
OSMemDumpPtr os_dump =
GetFakeOSMemDump(GetResidentValue(metrics_mb) * 1024,
metrics_mb["PrivateMemoryFootprint"] * 1024,
......@@ -161,6 +175,7 @@ MetricMap GetExpectedBrowserMetrics() {
#endif
{"Malloc", 20}, {"PrivateMemoryFootprint", 30},
{"SharedMemoryFootprint", 35}, {"Uptime", 42},
{"GpuMemory", kGpuTotalMemory * 1024 * 1024},
#if defined(OS_LINUX) || defined(OS_ANDROID)
{"PrivateSwapFootprint", 50},
#endif
......@@ -377,6 +392,12 @@ void PopulateGpuMetrics(GlobalMemoryDumpPtr& global_dump,
metrics_mb["Malloc"] * 1024 * 1024);
SetAllocatorDumpMetric(pmd, "gpu/gl", "effective_size",
metrics_mb["CommandBuffer"] * 1024 * 1024);
// These two categories are required for total gpu memory, but do not
// have a UKM value set for them, so don't appear in metrics_mb.
SetAllocatorDumpMetric(pmd, "gpu/shared-images", "effective_size",
kGpuSharedImagesSizeMB * 1024 * 1024);
SetAllocatorDumpMetric(pmd, "skia/gpu_resources", "effective_size",
kGpuSkiaGpuResourcesMB * 1024 * 1024);
OSMemDumpPtr os_dump =
GetFakeOSMemDump(GetResidentValue(metrics_mb) * 1024,
metrics_mb["PrivateMemoryFootprint"] * 1024,
......@@ -402,8 +423,9 @@ MetricMap GetExpectedGpuMetrics() {
{"Resident", 210},
#endif
{"Malloc", 220}, {"PrivateMemoryFootprint", 230},
{"SharedMemoryFootprint", 235}, {"CommandBuffer", 240},
{"Uptime", 42},
{"SharedMemoryFootprint", 235},
{"CommandBuffer", kGpuCommandBufferMB}, {"Uptime", 42},
{"GpuMemory", kGpuTotalMemory * 1024 * 1024},
#if defined(OS_LINUX) || defined(OS_ANDROID)
{"PrivateSwapFootprint", 50},
#endif
......
......@@ -157083,6 +157083,7 @@ should be kept until we use this API. -->
label="Only counting memory used by Discardable manager."/>
<suffix name="Extensions.ValueStore"
label="Only counting memory used by Extension value store database."/>
<suffix name="GpuMemory" label="Only counting memory allocated for the GPU."/>
<suffix name="JavaHeap"
label="Only counting memory used by Java heap in Android."/>
<suffix name="Malloc" label="Constrained to malloc allocator."/>
......@@ -3856,6 +3856,11 @@ be describing additional metrics about the same event.
process.
</summary>
</metric>
<metric name="GpuMemory">
<summary>
Measure of GPU memory used by Chrome.
</summary>
</metric>
<metric name="History">
<summary>
Approximate measure of memory consumed by History service.
......
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