Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2062)

Unified Diff: base/chromeos/memory_pressure_observer_chromeos.cc

Issue 874483008: Add UMA stats to get the quality of service of memory pressure handling scheme in ChromeOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address the code review comment. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/chromeos/memory_pressure_observer_chromeos.cc
diff --git a/base/chromeos/memory_pressure_observer_chromeos.cc b/base/chromeos/memory_pressure_observer_chromeos.cc
index 8112c761e5e713e747cb015d8226e62a754c87a8..81ce085805f96c1c71483d54748e6bc81f500396 100644
--- a/base/chromeos/memory_pressure_observer_chromeos.cc
+++ b/base/chromeos/memory_pressure_observer_chromeos.cc
@@ -5,6 +5,7 @@
#include "base/chromeos/memory_pressure_observer_chromeos.h"
#include "base/message_loop/message_loop.h"
+#include "base/metrics/histogram_macros.h"
#include "base/process/process_metrics.h"
#include "base/time/time.h"
@@ -74,11 +75,29 @@ MemoryPressureObserverChromeOS::MemoryPressureObserverChromeOS(
GetModerateMemoryThresholdInPercent(thresholds)),
critical_pressure_threshold_percent_(
GetCriticalMemoryThresholdInPercent(thresholds)),
+ non_critical_start_time_(TimeTicks::Now()),
+ critical_start_time_(TimeTicks::Now()),
weak_ptr_factory_(this) {
StartObserving();
}
MemoryPressureObserverChromeOS::~MemoryPressureObserverChromeOS() {
+ // Record the percentage for the last time.
+ if (GetMemoryPressureLevelFromFillLevel(
+ GetUsedMemoryInPercent(), moderate_pressure_threshold_percent_,
+ critical_pressure_threshold_percent_) ==
+ MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL) {
+ non_critical_delta_ = critical_start_time_ - non_critical_start_time_;
+ critical_delta_ = TimeTicks::Now() - critical_start_time_;
+ int percentage = (100 * non_critical_delta_.InMilliseconds()) /
+ ((non_critical_delta_ + critical_delta_).InMilliseconds());
Mr4D (OOO till 08-26) 2015/01/29 08:17:53 For line 90 - 93 I would create a function which c
xdai1 2015/01/31 00:01:39 Why should the function that writes the UMA stat b
+ UMA_HISTOGRAM_PERCENTAGE(
+ "ChromeOS.MemoryPressureHandleQuality.NonCriticalRatio", percentage);
+ } else {
+ UMA_HISTOGRAM_PERCENTAGE(
+ "ChromeOS.MemoryPressureHandleQuality.NonCriticalRatio", 100);
+ }
+
StopObserving();
}
@@ -108,6 +127,31 @@ void MemoryPressureObserverChromeOS::CheckMemoryPressure() {
GetMemoryPressureLevelFromFillLevel(GetUsedMemoryInPercent(),
moderate_pressure_threshold_percent_,
critical_pressure_threshold_percent_);
+
+ // Record quality of service of memory pressure handling scheme in ChromeOS.
Mr4D (OOO till 08-26) 2015/01/29 08:17:53 Maybe: // Record the quality of service for memor
xdai1 2015/01/31 00:01:39 Done.
+ if (old_pressure != current_memory_pressure_level_) {
+ if (old_pressure ==
+ MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL) {
+ critical_delta_ = TimeTicks::Now() - critical_start_time_;
Mr4D (OOO till 08-26) 2015/01/29 08:17:53 Note: As stated in the header file we do not need
xdai1 2015/01/31 00:01:39 Done.
+ non_critical_start_time_ = TimeTicks::Now();
+
Mr4D (OOO till 08-26) 2015/01/29 08:17:53 What about: When leaving the critical memory pre
xdai1 2015/01/31 00:01:39 Done.
+ // We compute the percentage of the system stayed in non-critical memory
+ // pressure state each time when the system left the critical memory
+ // pressure state. The larger the percentage is, the better the memory
+ // pressure handling scheme is.
+ int percentage =
+ (100 * non_critical_delta_.InMilliseconds()) /
+ ((non_critical_delta_ + critical_delta_).InMilliseconds());
+ UMA_HISTOGRAM_PERCENTAGE(
+ "ChromeOS.MemoryPressureHandleQuality.NonCriticalRatio", percentage);
+
+ } else if (current_memory_pressure_level_ ==
+ MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL) {
+ non_critical_delta_ = TimeTicks::Now() - non_critical_start_time_;
+ critical_start_time_ = TimeTicks::Now();
+ }
+ }
+
// In case there is no memory pressure we do not notify.
if (current_memory_pressure_level_ ==
MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE) {

Powered by Google App Engine
This is Rietveld 408576698