diff options
author | jamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-20 22:33:50 +0000 |
---|---|---|
committer | jamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-20 22:33:50 +0000 |
commit | 24c463a5c2044be8032ef575bd45075ced931832 (patch) | |
tree | ecdecf5d84e64383839abaf4e7f656273f2e01ed | |
parent | 93df9c4e0accc274dd90dde249224be03ed27e98 (diff) | |
download | chromium_src-24c463a5c2044be8032ef575bd45075ced931832.zip chromium_src-24c463a5c2044be8032ef575bd45075ced931832.tar.gz chromium_src-24c463a5c2044be8032ef575bd45075ced931832.tar.bz2 |
cros: Use UMA histograms for low memory statistics
* I was using HISTOGRAM_COUNTS instead of UMA_HISTOGRAM_COUNTS so the data wasn't getting uploaded.
* Also decrease the maximum histogram value to 1000 for discard and reload counts to get more precision on the low end. If a user has >1000 discard in a session we can just call their experience "bad".
BUG=none
TEST=none
TBR=sky@chromium.org for chrome/browser/ui/sad_tab_view.cc
Review URL: https://chromiumcodereview.appspot.com/10161012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133286 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/oom_priority_manager.cc | 19 | ||||
-rw-r--r-- | chrome/browser/ui/browser.cc | 6 | ||||
-rw-r--r-- | chrome/browser/ui/views/sad_tab_view.cc | 12 |
3 files changed, 23 insertions, 14 deletions
diff --git a/chrome/browser/oom_priority_manager.cc b/chrome/browser/oom_priority_manager.cc index 429f817..0d87d4c 100644 --- a/chrome/browser/oom_priority_manager.cc +++ b/chrome/browser/oom_priority_manager.cc @@ -54,10 +54,10 @@ namespace { // Record a time in seconds, over a potential interval of about a day. Must be a // macro and not a function because the histograms system requires a unique // static variable at the site of each call. -#define HISTOGRAM_SECONDS(name, sample) HISTOGRAM_CUSTOM_COUNTS( \ +#define UMA_HISTOGRAM_SECONDS(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ name, sample, 1, 10000, 50) // Record a size in megabytes, over a potential interval up to 32 GB. -#define HISTOGRAM_MEGABYTES(name, sample) HISTOGRAM_CUSTOM_COUNTS( \ +#define UMA_HISTOGRAM_MEGABYTES(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ name, sample, 1, 32768, 50) // The default interval in seconds after which to adjust the oom_score_adj @@ -241,10 +241,11 @@ bool OomPriorityManager::DiscardTabById(int64 target_web_contents_id) { void OomPriorityManager::RecordDiscardStatistics() { // Record a raw count so we can compare to discard reloads. discard_count_++; - HISTOGRAM_COUNTS_10000("Tabs.Discard.DiscardCount", discard_count_); + UMA_HISTOGRAM_CUSTOM_COUNTS( + "Tabs.Discard.DiscardCount", discard_count_, 1, 1000, 50); // TODO(jamescook): Maybe incorporate extension count? - HISTOGRAM_COUNTS_100("Tabs.Discard.TabCount", GetTabCount()); + UMA_HISTOGRAM_COUNTS_100("Tabs.Discard.TabCount", GetTabCount()); // TODO(jamescook): If the time stats prove too noisy, then divide up users // based on how heavily they use Chrome using tab count as a proxy. @@ -253,21 +254,23 @@ void OomPriorityManager::RecordDiscardStatistics() { // This is the first discard this session. TimeDelta interval = TimeTicks::Now() - start_time_; int interval_seconds = static_cast<int>(interval.InSeconds()); - HISTOGRAM_SECONDS("Tabs.Discard.InitialTime", interval_seconds); + UMA_HISTOGRAM_SECONDS("Tabs.Discard.InitialTime", interval_seconds); } else { // Not the first discard, so compute time since last discard. TimeDelta interval = TimeTicks::Now() - last_discard_time_; int interval_seconds = static_cast<int>(interval.InSeconds()); - HISTOGRAM_SECONDS("Tabs.Discard.IntervalTime", interval_seconds); + UMA_HISTOGRAM_SECONDS("Tabs.Discard.IntervalTime", interval_seconds); } // Record Chrome's concept of system memory usage at the time of the discard. base::SystemMemoryInfoKB memory; if (base::GetSystemMemoryInfo(&memory)) { int mem_anonymous_kb = memory.active_anon + memory.inactive_anon; - HISTOGRAM_MEGABYTES("Tabs.Discard.MemAnonymousMB", mem_anonymous_kb / 1024); + UMA_HISTOGRAM_MEGABYTES("Tabs.Discard.MemAnonymousMB", + mem_anonymous_kb / 1024); int mem_available_kb = memory.active_file + memory.inactive_file + memory.free; - HISTOGRAM_MEGABYTES("Tabs.Discard.MemAvailableMB", mem_available_kb / 1024); + UMA_HISTOGRAM_MEGABYTES("Tabs.Discard.MemAvailableMB", + mem_available_kb / 1024); } // Set up to record the next interval. last_discard_time_ = TimeTicks::Now(); diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index ed1722f..1dd9457 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -3272,7 +3272,8 @@ void Browser::ActiveTabChanged(TabContentsWrapper* old_contents, if (parsed_command_line.HasSwitch(switches::kReloadKilledTabs)) { LOG(WARNING) << "Reloading killed tab at " << index; static int reload_count = 0; - HISTOGRAM_COUNTS_10000("Tabs.SadTab.ReloadCount", ++reload_count); + UMA_HISTOGRAM_CUSTOM_COUNTS( + "Tabs.SadTab.ReloadCount", ++reload_count, 1, 1000, 50); Reload(CURRENT_TAB); did_reload = true; } @@ -3282,7 +3283,8 @@ void Browser::ActiveTabChanged(TabContentsWrapper* old_contents, if (!did_reload && IsTabDiscarded(index)) { LOG(WARNING) << "Reloading discarded tab at " << index; static int reload_count = 0; - HISTOGRAM_COUNTS_10000("Tabs.Discard.ReloadCount", ++reload_count); + UMA_HISTOGRAM_CUSTOM_COUNTS( + "Tabs.Discard.ReloadCount", ++reload_count, 1, 1000, 50); Reload(CURRENT_TAB); } diff --git a/chrome/browser/ui/views/sad_tab_view.cc b/chrome/browser/ui/views/sad_tab_view.cc index 560cc52..ea8de2c 100644 --- a/chrome/browser/ui/views/sad_tab_view.cc +++ b/chrome/browser/ui/views/sad_tab_view.cc @@ -70,12 +70,14 @@ SadTabView::SadTabView(WebContents* web_contents, Kind kind) switch (kind_) { case CRASHED: { static int crashed = 0; - HISTOGRAM_COUNTS_10000("Tabs.SadTab.CrashCreated", ++crashed); + UMA_HISTOGRAM_CUSTOM_COUNTS( + "Tabs.SadTab.CrashCreated", ++crashed, 1, 1000, 50); break; } case KILLED: { static int killed = 0; - HISTOGRAM_COUNTS_10000("Tabs.SadTab.KillCreated", ++killed); + UMA_HISTOGRAM_CUSTOM_COUNTS( + "Tabs.SadTab.KillCreated", ++killed, 1, 1000, 50); break; } default: @@ -211,12 +213,14 @@ void SadTabView::OnPaint(gfx::Canvas* canvas) { switch (kind_) { case CRASHED: { static int crashed = 0; - HISTOGRAM_COUNTS_10000("Tabs.SadTab.CrashDisplayed", ++crashed); + UMA_HISTOGRAM_CUSTOM_COUNTS( + "Tabs.SadTab.CrashDisplayed", ++crashed, 1, 1000, 50); break; } case KILLED: { static int killed = 0; - HISTOGRAM_COUNTS_10000("Tabs.SadTab.KillDisplayed", ++killed); + UMA_HISTOGRAM_CUSTOM_COUNTS( + "Tabs.SadTab.KillDisplayed", ++killed, 1, 1000, 50); break; } default: |