OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/metrics/process_memory_metrics_emitter.h" | 5 #include "chrome/browser/metrics/process_memory_metrics_emitter.h" |
6 | 6 |
7 #include "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
8 #include "base/trace_event/memory_dump_request_args.h" | 8 #include "base/trace_event/memory_dump_request_args.h" |
9 #include "content/public/common/service_manager_connection.h" | 9 #include "content/public/common/service_manager_connection.h" |
10 #include "content/public/common/service_names.mojom.h" | 10 #include "content/public/common/service_names.mojom.h" |
11 #include "services/service_manager/public/cpp/connector.h" | 11 #include "services/service_manager/public/cpp/connector.h" |
12 | 12 |
13 using ProcessMemoryDumpPtr = | 13 using ProcessMemoryDumpPtr = |
14 memory_instrumentation::mojom::ProcessMemoryDumpPtr; | 14 memory_instrumentation::mojom::ProcessMemoryDumpPtr; |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 void EmitBrowserMemoryMetrics(const ProcessMemoryDumpPtr& pmd) { | 18 void EmitBrowserMemoryMetrics(const ProcessMemoryDumpPtr& pmd) { |
19 UMA_HISTOGRAM_MEMORY_LARGE_MB("Memory.Experimental.Browser2.Resident", | 19 UMA_HISTOGRAM_MEMORY_LARGE_MB("Memory.Experimental.Browser2.Resident", |
20 pmd->os_dump.resident_set_kb * 1024); | 20 pmd->os_dump.resident_set_kb / 1024); |
21 UMA_HISTOGRAM_MEMORY_LARGE_MB("Memory.Experimental.Browser2.Malloc", | 21 UMA_HISTOGRAM_MEMORY_LARGE_MB("Memory.Experimental.Browser2.Malloc", |
22 pmd->chrome_dump.malloc_total_kb * 1024); | 22 pmd->chrome_dump.malloc_total_kb / 1024); |
23 | 23 UMA_HISTOGRAM_MEMORY_LARGE_MB( |
24 // TODO(erikchen): Emit private memory footprint. https://crbug.com/721434. | 24 "Memory.Experimental.Browser2.PrivateMemoryFootprint", |
| 25 pmd->private_footprint / 1024); |
25 } | 26 } |
26 | 27 |
27 void EmitRendererMemoryMetrics(const ProcessMemoryDumpPtr& pmd) { | 28 void EmitRendererMemoryMetrics(const ProcessMemoryDumpPtr& pmd) { |
28 UMA_HISTOGRAM_MEMORY_LARGE_MB("Memory.Experimental.Renderer2.Resident", | 29 UMA_HISTOGRAM_MEMORY_LARGE_MB("Memory.Experimental.Renderer2.Resident", |
29 pmd->os_dump.resident_set_kb * 1024); | 30 pmd->os_dump.resident_set_kb / 1024); |
| 31 UMA_HISTOGRAM_MEMORY_LARGE_MB( |
| 32 "Memory.Experimental.Renderer2.PrivateMemoryFootprint", |
| 33 pmd->private_footprint / 1024); |
30 UMA_HISTOGRAM_MEMORY_LARGE_MB("Memory.Experimental.Renderer2.Malloc", | 34 UMA_HISTOGRAM_MEMORY_LARGE_MB("Memory.Experimental.Renderer2.Malloc", |
31 pmd->chrome_dump.malloc_total_kb * 1024); | 35 pmd->chrome_dump.malloc_total_kb / 1024); |
32 UMA_HISTOGRAM_MEMORY_LARGE_MB( | 36 UMA_HISTOGRAM_MEMORY_LARGE_MB( |
33 "Memory.Experimental.Renderer2.PartitionAlloc", | 37 "Memory.Experimental.Renderer2.PartitionAlloc", |
34 pmd->chrome_dump.partition_alloc_total_kb * 1024); | 38 pmd->chrome_dump.partition_alloc_total_kb / 1024); |
35 UMA_HISTOGRAM_MEMORY_LARGE_MB("Memory.Experimental.Renderer2.BlinkGC", | 39 UMA_HISTOGRAM_MEMORY_LARGE_MB("Memory.Experimental.Renderer2.BlinkGC", |
36 pmd->chrome_dump.blink_gc_total_kb * 1024); | 40 pmd->chrome_dump.blink_gc_total_kb / 1024); |
37 UMA_HISTOGRAM_MEMORY_LARGE_MB("Memory.Experimental.Renderer2.V8", | 41 UMA_HISTOGRAM_MEMORY_LARGE_MB("Memory.Experimental.Renderer2.V8", |
38 pmd->chrome_dump.v8_total_kb * 1024); | 42 pmd->chrome_dump.v8_total_kb / 1024); |
39 | |
40 // TODO(erikchen): Emit private memory footprint. https://crbug.com/721434. | |
41 } | 43 } |
42 | 44 |
43 void EmitGpuMemoryMetrics(const ProcessMemoryDumpPtr& pmd) { | 45 void EmitGpuMemoryMetrics(const ProcessMemoryDumpPtr& pmd) { |
44 UMA_HISTOGRAM_MEMORY_LARGE_MB("Memory.Experimental.Gpu2.Resident", | 46 UMA_HISTOGRAM_MEMORY_LARGE_MB("Memory.Experimental.Gpu2.Resident", |
45 pmd->os_dump.resident_set_kb * 1024); | 47 pmd->os_dump.resident_set_kb / 1024); |
46 UMA_HISTOGRAM_MEMORY_LARGE_MB("Memory.Experimental.Gpu2.Malloc", | 48 UMA_HISTOGRAM_MEMORY_LARGE_MB("Memory.Experimental.Gpu2.Malloc", |
47 pmd->chrome_dump.malloc_total_kb * 1024); | 49 pmd->chrome_dump.malloc_total_kb / 1024); |
48 | 50 UMA_HISTOGRAM_MEMORY_LARGE_MB( |
49 // TODO(erikchen): Emit private memory footprint. https://crbug.com/721434. | 51 "Memory.Experimental.Gpu2.PrivateMemoryFootprint", |
| 52 pmd->private_footprint / 1024); |
50 } | 53 } |
51 | 54 |
52 } // namespace | 55 } // namespace |
53 | 56 |
54 ProcessMemoryMetricsEmitter::ProcessMemoryMetricsEmitter() {} | 57 ProcessMemoryMetricsEmitter::ProcessMemoryMetricsEmitter() {} |
55 | 58 |
56 void ProcessMemoryMetricsEmitter::FetchAndEmitProcessMemoryMetrics() { | 59 void ProcessMemoryMetricsEmitter::FetchAndEmitProcessMemoryMetrics() { |
57 service_manager::Connector* connector = | 60 service_manager::Connector* connector = |
58 content::ServiceManagerConnection::GetForProcess()->GetConnector(); | 61 content::ServiceManagerConnection::GetForProcess()->GetConnector(); |
59 connector->BindInterface(content::mojom::kBrowserServiceName, | 62 connector->BindInterface(content::mojom::kBrowserServiceName, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 case memory_instrumentation::mojom::ProcessType::GPU: | 94 case memory_instrumentation::mojom::ProcessType::GPU: |
92 EmitGpuMemoryMetrics(pmd); | 95 EmitGpuMemoryMetrics(pmd); |
93 break; | 96 break; |
94 case memory_instrumentation::mojom::ProcessType::UTILITY: | 97 case memory_instrumentation::mojom::ProcessType::UTILITY: |
95 case memory_instrumentation::mojom::ProcessType::PLUGIN: | 98 case memory_instrumentation::mojom::ProcessType::PLUGIN: |
96 case memory_instrumentation::mojom::ProcessType::OTHER: | 99 case memory_instrumentation::mojom::ProcessType::OTHER: |
97 break; | 100 break; |
98 } | 101 } |
99 } | 102 } |
100 } | 103 } |
OLD | NEW |