| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/metrics_memory_details.h" | 5 #include "chrome/browser/metrics/metrics_memory_details.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 MetricsMemoryDetails::~MetricsMemoryDetails() { | 65 MetricsMemoryDetails::~MetricsMemoryDetails() { |
| 66 } | 66 } |
| 67 | 67 |
| 68 void MetricsMemoryDetails::OnDetailsAvailable() { | 68 void MetricsMemoryDetails::OnDetailsAvailable() { |
| 69 UpdateHistograms(); | 69 UpdateHistograms(); |
| 70 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback_); | 70 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback_); |
| 71 } | 71 } |
| 72 | 72 |
| 73 void MetricsMemoryDetails::UpdateHistograms() { | 73 void MetricsMemoryDetails::UpdateHistograms() { |
| 74 // Reports a set of memory metrics to UMA. | 74 // Reports a set of memory metrics to UMA. |
| 75 // Memory is measured in KB. | |
| 76 | 75 |
| 77 const ProcessData& browser = *ChromeBrowser(); | 76 const ProcessData& browser = *ChromeBrowser(); |
| 78 size_t aggregate_memory = 0; | 77 size_t aggregate_memory = 0; |
| 79 int chrome_count = 0; | 78 int chrome_count = 0; |
| 80 int extension_count = 0; | 79 int extension_count = 0; |
| 81 int pepper_plugin_count = 0; | 80 int pepper_plugin_count = 0; |
| 82 int pepper_plugin_broker_count = 0; | 81 int pepper_plugin_broker_count = 0; |
| 83 int renderer_count = 0; | 82 int renderer_count = 0; |
| 84 int other_count = 0; | 83 int other_count = 0; |
| 85 int worker_count = 0; | 84 int worker_count = 0; |
| 86 int process_limit = content::RenderProcessHost::GetMaxRendererProcessCount(); | 85 int process_limit = content::RenderProcessHost::GetMaxRendererProcessCount(); |
| 87 for (size_t index = 0; index < browser.processes.size(); index++) { | 86 for (size_t index = 0; index < browser.processes.size(); index++) { |
| 88 int sample = static_cast<int>(browser.processes[index].working_set.priv); | 87 int sample = static_cast<int>(browser.processes[index].working_set.priv); |
| 89 size_t committed = browser.processes[index].committed.priv + | 88 size_t committed = browser.processes[index].committed.priv + |
| 90 browser.processes[index].committed.mapped + | 89 browser.processes[index].committed.mapped + |
| 91 browser.processes[index].committed.image; | 90 browser.processes[index].committed.image; |
| 92 aggregate_memory += sample; | 91 aggregate_memory += sample; |
| 93 switch (browser.processes[index].process_type) { | 92 switch (browser.processes[index].process_type) { |
| 94 case content::PROCESS_TYPE_BROWSER: | 93 case content::PROCESS_TYPE_BROWSER: |
| 95 UMA_HISTOGRAM_MEMORY_LARGE_MB("Memory.Browser.Large2", sample / 1024); | 94 UMA_HISTOGRAM_MEMORY_LARGE_MB("Memory.Browser.Large2", sample / 1024); |
| 96 UMA_HISTOGRAM_MEMORY_LARGE_MB("Memory.Browser.Committed", | 95 UMA_HISTOGRAM_MEMORY_LARGE_MB("Memory.Browser.Committed", |
| 97 committed / 1024); | 96 committed / 1024); |
| 98 continue; | 97 continue; |
| 99 case content::PROCESS_TYPE_RENDERER: { | 98 case content::PROCESS_TYPE_RENDERER: { |
| 99 UMA_HISTOGRAM_MEMORY_LARGE_MB("Memory.RendererAll", sample / 1024); |
| 100 UMA_HISTOGRAM_MEMORY_LARGE_MB("Memory.RendererAll.Committed", |
| 101 committed / 1024); |
| 100 ProcessMemoryInformation::RendererProcessType renderer_type = | 102 ProcessMemoryInformation::RendererProcessType renderer_type = |
| 101 browser.processes[index].renderer_type; | 103 browser.processes[index].renderer_type; |
| 102 switch (renderer_type) { | 104 switch (renderer_type) { |
| 103 case ProcessMemoryInformation::RENDERER_EXTENSION: | 105 case ProcessMemoryInformation::RENDERER_EXTENSION: |
| 104 UMA_HISTOGRAM_MEMORY_KB("Memory.Extension", sample); | 106 UMA_HISTOGRAM_MEMORY_KB("Memory.Extension", sample); |
| 105 extension_count++; | 107 extension_count++; |
| 106 continue; | 108 continue; |
| 107 case ProcessMemoryInformation::RENDERER_CHROME: | 109 case ProcessMemoryInformation::RENDERER_CHROME: |
| 108 UMA_HISTOGRAM_MEMORY_KB("Memory.Chrome", sample); | 110 UMA_HISTOGRAM_MEMORY_KB("Memory.Chrome", sample); |
| 109 chrome_count++; | 111 chrome_count++; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 UMA_HISTOGRAM_COUNTS_100("Memory.OtherProcessCount", other_count); | 195 UMA_HISTOGRAM_COUNTS_100("Memory.OtherProcessCount", other_count); |
| 194 UMA_HISTOGRAM_COUNTS_100("Memory.PepperPluginProcessCount", | 196 UMA_HISTOGRAM_COUNTS_100("Memory.PepperPluginProcessCount", |
| 195 pepper_plugin_count); | 197 pepper_plugin_count); |
| 196 UMA_HISTOGRAM_COUNTS_100("Memory.PepperPluginBrokerProcessCount", | 198 UMA_HISTOGRAM_COUNTS_100("Memory.PepperPluginBrokerProcessCount", |
| 197 pepper_plugin_broker_count); | 199 pepper_plugin_broker_count); |
| 198 UMA_HISTOGRAM_COUNTS_100("Memory.RendererProcessCount", renderer_count); | 200 UMA_HISTOGRAM_COUNTS_100("Memory.RendererProcessCount", renderer_count); |
| 199 UMA_HISTOGRAM_COUNTS_100("Memory.WorkerProcessCount", worker_count); | 201 UMA_HISTOGRAM_COUNTS_100("Memory.WorkerProcessCount", worker_count); |
| 200 // TODO(viettrungluu): Do we want separate counts for the other | 202 // TODO(viettrungluu): Do we want separate counts for the other |
| 201 // (platform-specific) process types? | 203 // (platform-specific) process types? |
| 202 | 204 |
| 203 // TODO(rkaplow): Remove once we've verified Memory.Total2 is ok. | |
| 204 int total_sample_old = static_cast<int>(aggregate_memory / 1000); | |
| 205 UMA_HISTOGRAM_MEMORY_MB("Memory.Total", total_sample_old); | |
| 206 int total_sample = static_cast<int>(aggregate_memory / 1024); | 205 int total_sample = static_cast<int>(aggregate_memory / 1024); |
| 207 UMA_HISTOGRAM_MEMORY_LARGE_MB("Memory.Total2", total_sample); | 206 UMA_HISTOGRAM_MEMORY_LARGE_MB("Memory.Total2", total_sample); |
| 208 | 207 |
| 209 // Predict the number of processes needed when isolating all sites and when | 208 // Predict the number of processes needed when isolating all sites and when |
| 210 // isolating only HTTPS sites. | 209 // isolating only HTTPS sites. |
| 211 int all_renderer_count = renderer_count + chrome_count + extension_count; | 210 int all_renderer_count = renderer_count + chrome_count + extension_count; |
| 212 int non_renderer_count = browser.processes.size() - all_renderer_count; | 211 int non_renderer_count = browser.processes.size() - all_renderer_count; |
| 213 DCHECK_GE(non_renderer_count, 1); | 212 DCHECK_GE(non_renderer_count, 1); |
| 214 SiteDetails::UpdateHistograms(browser.site_data, all_renderer_count, | 213 SiteDetails::UpdateHistograms(browser.site_data, all_renderer_count, |
| 215 non_renderer_count); | 214 non_renderer_count); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 UMA_HISTOGRAM_CUSTOM_COUNTS("Memory.Swap.NumWrites", swap_info().num_writes, | 304 UMA_HISTOGRAM_CUSTOM_COUNTS("Memory.Swap.NumWrites", swap_info().num_writes, |
| 306 1, 100000000, 100); | 305 1, 100000000, 100); |
| 307 | 306 |
| 308 if (swap_info().orig_data_size > 0 && swap_info().compr_data_size > 0) { | 307 if (swap_info().orig_data_size > 0 && swap_info().compr_data_size > 0) { |
| 309 UMA_HISTOGRAM_CUSTOM_COUNTS( | 308 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 310 "Memory.Swap.CompressionRatio", | 309 "Memory.Swap.CompressionRatio", |
| 311 swap_info().orig_data_size / swap_info().compr_data_size, 1, 20, 20); | 310 swap_info().orig_data_size / swap_info().compr_data_size, 1, 20, 20); |
| 312 } | 311 } |
| 313 } | 312 } |
| 314 #endif // defined(OS_CHROMEOS) | 313 #endif // defined(OS_CHROMEOS) |
| OLD | NEW |