diff options
author | oysteine <oysteine@chromium.org> | 2014-12-10 13:43:57 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-12-10 21:44:25 +0000 |
commit | de73132d9c33c35c867e1a160aebb815a3463f1d (patch) | |
tree | f2b849705014b739d5f9a47130c74705292c0f57 | |
parent | 69cf1d7508421db72a72dc920f3044de88605d00 (diff) | |
download | chromium_src-de73132d9c33c35c867e1a160aebb815a3463f1d.zip chromium_src-de73132d9c33c35c867e1a160aebb815a3463f1d.tar.gz chromium_src-de73132d9c33c35c867e1a160aebb815a3463f1d.tar.bz2 |
Performance monitor: Cleaned up more unused code after the about://performance removal
R=simonhatch
BUG=
Review URL: https://codereview.chromium.org/788063002
Cr-Commit-Position: refs/heads/master@{#307773}
3 files changed, 34 insertions, 107 deletions
diff --git a/chrome/browser/performance_monitor/performance_monitor.cc b/chrome/browser/performance_monitor/performance_monitor.cc index b52ab6f..5cf2ce4 100644 --- a/chrome/browser/performance_monitor/performance_monitor.cc +++ b/chrome/browser/performance_monitor/performance_monitor.cc @@ -48,15 +48,13 @@ void PerformanceMonitor::StartGatherCycle() { DCHECK_CURRENTLY_ON(BrowserThread::UI); repeating_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(kGatherIntervalInSeconds), - this, - &PerformanceMonitor::GatherMetricsMapOnUIThread); + this, &PerformanceMonitor::GatherMetricsMapOnUIThread); } namespace { -void GatherMetricsForRenderProcess( - content::RenderProcessHost* host, - ProcessMetricsMetadata& data) { +void GatherMetricsForRenderProcess(content::RenderProcessHost* host, + ProcessMetricsMetadata& data) { DCHECK_CURRENTLY_ON(BrowserThread::UI); #if defined(ENABLE_EXTENSIONS) content::BrowserContext* browser_context = host->GetBrowserContext(); @@ -88,7 +86,7 @@ void GatherMetricsForRenderProcess( #endif } -} // namespace +} // namespace void PerformanceMonitor::GatherMetricsMapOnUIThread() { DCHECK_CURRENTLY_ON(BrowserThread::UI); @@ -112,11 +110,9 @@ void PerformanceMonitor::GatherMetricsMapOnUIThread() { } BrowserThread::PostTask( - BrowserThread::IO, - FROM_HERE, + BrowserThread::IO, FROM_HERE, base::Bind(&PerformanceMonitor::GatherMetricsMapOnIOThread, - base::Unretained(this), - current_update_sequence)); + base::Unretained(this), current_update_sequence)); } void PerformanceMonitor::MarkProcessAsAlive( @@ -163,10 +159,6 @@ void PerformanceMonitor::GatherMetricsMapOnIOThread( browser_process_data.handle = base::GetCurrentProcessHandle(); MarkProcessAsAlive(browser_process_data, current_update_sequence); - double cpu_usage = 0.0; - size_t private_memory_sum = 0; - size_t shared_memory_sum = 0; - // Update metrics for all watched processes; remove dead entries from the map. MetricsMap::iterator iter = metrics_map_.begin(); while (iter != metrics_map_.end()) { @@ -176,18 +168,6 @@ void PerformanceMonitor::GatherMetricsMapOnIOThread( metrics_map_.erase(iter++); } else { process_metrics.SampleMetrics(); - - // Gather averages of previously sampled metrics. - cpu_usage += process_metrics.GetAverageCPUUsage(); - - size_t private_memory = 0; - size_t shared_memory = 0; - process_metrics.GetAverageMemoryBytes(&private_memory, &shared_memory); - private_memory_sum += private_memory; - shared_memory_sum += shared_memory; - - process_metrics.EndOfCycle(); - ++iter; } } diff --git a/chrome/browser/performance_monitor/process_metrics_history.cc b/chrome/browser/performance_monitor/process_metrics_history.cc index 70a9799f..10263d8 100644 --- a/chrome/browser/performance_monitor/process_metrics_history.cc +++ b/chrome/browser/performance_monitor/process_metrics_history.cc @@ -22,18 +22,10 @@ namespace performance_monitor { const float kHighCPUUtilizationThreshold = 90.0f; ProcessMetricsHistory::ProcessMetricsHistory() - : last_update_sequence_(0) { - ResetCounters(); + : last_update_sequence_(0), cpu_usage_(0.0) { } -ProcessMetricsHistory::~ProcessMetricsHistory() {} - -void ProcessMetricsHistory::ResetCounters() { - min_cpu_usage_ = std::numeric_limits<double>::max(); - accumulated_cpu_usage_ = 0.0; - accumulated_private_bytes_ = 0; - accumulated_shared_bytes_ = 0; - sample_count_ = 0; +ProcessMetricsHistory::~ProcessMetricsHistory() { } void ProcessMetricsHistory::Initialize( @@ -54,80 +46,60 @@ void ProcessMetricsHistory::Initialize( } void ProcessMetricsHistory::SampleMetrics() { - double cpu_usage = process_metrics_->GetPlatformIndependentCPUUsage(); - min_cpu_usage_ = std::min(min_cpu_usage_, cpu_usage); - accumulated_cpu_usage_ += cpu_usage; - - size_t private_bytes = 0; - size_t shared_bytes = 0; - if (!process_metrics_->GetMemoryBytes(&private_bytes, &shared_bytes)) - LOG(WARNING) << "GetMemoryBytes returned NULL (platform-specific error)"; + cpu_usage_ = process_metrics_->GetPlatformIndependentCPUUsage(); - accumulated_private_bytes_ += private_bytes; - accumulated_shared_bytes_ += shared_bytes; - - sample_count_++; -} - -void ProcessMetricsHistory::EndOfCycle() { RunPerformanceTriggers(); - ResetCounters(); } void ProcessMetricsHistory::RunPerformanceTriggers() { - if (sample_count_ == 0) - return; - // We scale up to the equivalent of 64 CPU cores fully loaded. More than this // doesn't really matter, as we're already in a terrible place. const int kHistogramMin = 0; const int kHistogramMax = 6400; const int kHistogramBucketCount = 50; - const double average_cpu_usage = accumulated_cpu_usage_ / sample_count_; - // The histogram macros don't support variables as histogram names, // hence the macro duplication for each process type. switch (process_data_.process_type) { case content::PROCESS_TYPE_BROWSER: UMA_HISTOGRAM_CUSTOM_COUNTS( - "PerformanceMonitor.AverageCPU.BrowserProcess", average_cpu_usage, + "PerformanceMonitor.AverageCPU.BrowserProcess", cpu_usage_, kHistogramMin, kHistogramMax, kHistogramBucketCount); // If CPU usage has consistently been above our threshold, // we *may* have an issue. - if (min_cpu_usage_ > kHighCPUUtilizationThreshold) { + if (cpu_usage_ > kHighCPUUtilizationThreshold) { UMA_HISTOGRAM_BOOLEAN("PerformanceMonitor.HighCPU.BrowserProcess", true); } break; case content::PROCESS_TYPE_RENDERER: UMA_HISTOGRAM_CUSTOM_COUNTS( - "PerformanceMonitor.AverageCPU.RendererProcess", average_cpu_usage, + "PerformanceMonitor.AverageCPU.RendererProcess", cpu_usage_, kHistogramMin, kHistogramMax, kHistogramBucketCount); - if (min_cpu_usage_ > kHighCPUUtilizationThreshold) { + if (cpu_usage_ > kHighCPUUtilizationThreshold) { UMA_HISTOGRAM_BOOLEAN("PerformanceMonitor.HighCPU.RendererProcess", true); } break; case content::PROCESS_TYPE_PLUGIN: - UMA_HISTOGRAM_CUSTOM_COUNTS( - "PerformanceMonitor.AverageCPU.PluginProcess", average_cpu_usage, - kHistogramMin, kHistogramMax, kHistogramBucketCount); - if (min_cpu_usage_ > kHighCPUUtilizationThreshold) + UMA_HISTOGRAM_CUSTOM_COUNTS("PerformanceMonitor.AverageCPU.PluginProcess", + cpu_usage_, kHistogramMin, kHistogramMax, + kHistogramBucketCount); + if (cpu_usage_ > kHighCPUUtilizationThreshold) UMA_HISTOGRAM_BOOLEAN("PerformanceMonitor.HighCPU.PluginProcess", true); break; case content::PROCESS_TYPE_GPU: - UMA_HISTOGRAM_CUSTOM_COUNTS( - "PerformanceMonitor.AverageCPU.GPUProcess", average_cpu_usage, - kHistogramMin, kHistogramMax, kHistogramBucketCount); - if (min_cpu_usage_ > kHighCPUUtilizationThreshold) + UMA_HISTOGRAM_CUSTOM_COUNTS("PerformanceMonitor.AverageCPU.GPUProcess", + cpu_usage_, kHistogramMin, kHistogramMax, + kHistogramBucketCount); + if (cpu_usage_ > kHighCPUUtilizationThreshold) UMA_HISTOGRAM_BOOLEAN("PerformanceMonitor.HighCPU.GPUProcess", true); break; case content::PROCESS_TYPE_PPAPI_PLUGIN: - UMA_HISTOGRAM_CUSTOM_COUNTS( - "PerformanceMonitor.AverageCPU.PPAPIProcess", average_cpu_usage, - kHistogramMin, kHistogramMax, kHistogramBucketCount); - if (min_cpu_usage_ > kHighCPUUtilizationThreshold) + UMA_HISTOGRAM_CUSTOM_COUNTS("PerformanceMonitor.AverageCPU.PPAPIProcess", + cpu_usage_, kHistogramMin, kHistogramMax, + kHistogramBucketCount); + if (cpu_usage_ > kHighCPUUtilizationThreshold) UMA_HISTOGRAM_BOOLEAN("PerformanceMonitor.HighCPU.PPAPIProcess", true); break; default: @@ -139,10 +111,9 @@ void ProcessMetricsHistory::RunPerformanceTriggers() { break; case kProcessSubtypePPAPIFlash: UMA_HISTOGRAM_CUSTOM_COUNTS( - "PerformanceMonitor.AverageCPU.PPAPIFlashProcess", - average_cpu_usage, kHistogramMin, kHistogramMax, - kHistogramBucketCount); - if (min_cpu_usage_ > kHighCPUUtilizationThreshold) { + "PerformanceMonitor.AverageCPU.PPAPIFlashProcess", cpu_usage_, + kHistogramMin, kHistogramMax, kHistogramBucketCount); + if (cpu_usage_ > kHighCPUUtilizationThreshold) { UMA_HISTOGRAM_BOOLEAN("PerformanceMonitor.HighCPU.PPAPIFlashProcess", true); } @@ -150,9 +121,8 @@ void ProcessMetricsHistory::RunPerformanceTriggers() { case kProcessSubtypeExtensionPersistent: UMA_HISTOGRAM_CUSTOM_COUNTS( "PerformanceMonitor.AverageCPU.RendererExtensionPersistentProcess", - average_cpu_usage, kHistogramMin, kHistogramMax, - kHistogramBucketCount); - if (min_cpu_usage_ > kHighCPUUtilizationThreshold) { + cpu_usage_, kHistogramMin, kHistogramMax, kHistogramBucketCount); + if (cpu_usage_ > kHighCPUUtilizationThreshold) { UMA_HISTOGRAM_BOOLEAN( "PerformanceMonitor.HighCPU.RendererExtensionPersistentProcess", true); @@ -161,9 +131,8 @@ void ProcessMetricsHistory::RunPerformanceTriggers() { case kProcessSubtypeExtensionEvent: UMA_HISTOGRAM_CUSTOM_COUNTS( "PerformanceMonitor.AverageCPU.RendererExtensionEventProcess", - average_cpu_usage, kHistogramMin, kHistogramMax, - kHistogramBucketCount); - if (min_cpu_usage_ > kHighCPUUtilizationThreshold) { + cpu_usage_, kHistogramMin, kHistogramMax, kHistogramBucketCount); + if (cpu_usage_ > kHighCPUUtilizationThreshold) { UMA_HISTOGRAM_BOOLEAN( "PerformanceMonitor.HighCPU.RendererExtensionEventProcess", true); } diff --git a/chrome/browser/performance_monitor/process_metrics_history.h b/chrome/browser/performance_monitor/process_metrics_history.h index 155c42d..21f8740 100644 --- a/chrome/browser/performance_monitor/process_metrics_history.h +++ b/chrome/browser/performance_monitor/process_metrics_history.h @@ -30,8 +30,7 @@ struct ProcessMetricsMetadata { ProcessMetricsMetadata() : handle(base::kNullProcessHandle), process_type(content::PROCESS_TYPE_UNKNOWN), - process_subtype(kProcessSubtypeUnknown) { - } + process_subtype(kProcessSubtypeUnknown) {} }; class ProcessMetricsHistory { @@ -43,10 +42,6 @@ class ProcessMetricsHistory { void Initialize(const ProcessMetricsMetadata& process_data, int initial_update_sequence); - // End of a measurement cycle; check for performance issues and reset - // accumulated statistics. - void EndOfCycle(); - // Gather metrics for the process and accumulate with past data. void SampleMetrics(); @@ -58,20 +53,7 @@ class ProcessMetricsHistory { int last_update_sequence() const { return last_update_sequence_; } - // Average CPU over all the past sampling points since last reset. - double GetAverageCPUUsage() const { - return accumulated_cpu_usage_ / sample_count_; - } - - // Average mem usage over all the past sampling points since last reset. - void GetAverageMemoryBytes(size_t* private_bytes, - size_t* shared_bytes) const { - *private_bytes = accumulated_private_bytes_ / sample_count_; - *shared_bytes = accumulated_shared_bytes_ / sample_count_; - } - private: - void ResetCounters(); void RunPerformanceTriggers(); // May not be fully populated. e.g. no |id| and no |name| for browser and @@ -80,11 +62,7 @@ class ProcessMetricsHistory { linked_ptr<base::ProcessMetrics> process_metrics_; int last_update_sequence_; - double accumulated_cpu_usage_; - double min_cpu_usage_; - size_t accumulated_private_bytes_; - size_t accumulated_shared_bytes_; - int sample_count_; + double cpu_usage_; DISALLOW_ASSIGN(ProcessMetricsHistory); }; |