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

Side by Side Diff: chrome/browser/chromeos/memory/oom_priority_manager.cc

Issue 11475016: cros: Add UMA stat for graphics driver memory on tab discard (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Log graphics on discard, fix anon mem range Created 8 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/chromeos/memory/oom_priority_manager.h" 5 #include "chrome/browser/chromeos/memory/oom_priority_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/metrics/field_trial.h" 14 #include "base/metrics/field_trial.h"
15 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
16 #include "base/process.h" 16 #include "base/process.h"
17 #include "base/process_util.h" 17 #include "base/process_util.h"
18 #include "base/string16.h" 18 #include "base/string16.h"
19 #include "base/string_number_conversions.h" 19 #include "base/string_number_conversions.h"
20 #include "base/stringprintf.h"
20 #include "base/synchronization/lock.h" 21 #include "base/synchronization/lock.h"
21 #include "base/threading/thread.h" 22 #include "base/threading/thread.h"
22 #include "base/time.h" 23 #include "base/time.h"
23 #include "base/utf_string_conversions.h" 24 #include "base/utf_string_conversions.h"
24 #include "build/build_config.h" 25 #include "build/build_config.h"
25 #include "chrome/browser/browser_process.h" 26 #include "chrome/browser/browser_process.h"
26 #include "chrome/browser/chromeos/memory/low_memory_observer.h" 27 #include "chrome/browser/chromeos/memory/low_memory_observer.h"
27 #include "chrome/browser/memory_details.h" 28 #include "chrome/browser/memory_details.h"
28 #include "chrome/browser/ui/browser.h" 29 #include "chrome/browser/ui/browser.h"
29 #include "chrome/browser/ui/browser_list.h" 30 #include "chrome/browser/ui/browser_list.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 104
104 OomMemoryDetails::OomMemoryDetails() { 105 OomMemoryDetails::OomMemoryDetails() {
105 AddRef(); // Released in OnDetailsAvailable(). 106 AddRef(); // Released in OnDetailsAvailable().
106 start_time_ = TimeTicks::Now(); 107 start_time_ = TimeTicks::Now();
107 } 108 }
108 109
109 void OomMemoryDetails::OnDetailsAvailable() { 110 void OomMemoryDetails::OnDetailsAvailable() {
110 TimeDelta delta = TimeTicks::Now() - start_time_; 111 TimeDelta delta = TimeTicks::Now() - start_time_;
111 // These logs are collected by user feedback reports. We want them to help 112 // These logs are collected by user feedback reports. We want them to help
112 // diagnose user-reported problems with frequently discarded tabs. 113 // diagnose user-reported problems with frequently discarded tabs.
114 std::string log_string = ToLogString();
115 base::SystemMemoryInfoKB memory;
116 if (base::GetSystemMemoryInfo(&memory) && memory.gem_size != -1) {
117 log_string += StringPrintf("Graphics %lld MB",
118 memory.gem_size / 1024 / 1024);
DaveMoore 2012/12/07 18:52:48 Use ui::FormatBytes() instead. You can find it in
James Cook 2012/12/07 19:41:22 Done.
119 }
113 LOG(WARNING) << "OOM details (" << delta.InMilliseconds() << " ms):\n" 120 LOG(WARNING) << "OOM details (" << delta.InMilliseconds() << " ms):\n"
114 << ToLogString(); 121 << log_string;
115 if (g_browser_process && g_browser_process->oom_priority_manager()) 122 if (g_browser_process && g_browser_process->oom_priority_manager())
116 g_browser_process->oom_priority_manager()->DiscardTab(); 123 g_browser_process->oom_priority_manager()->DiscardTab();
117 // Delete ourselves so we don't have to worry about OomPriorityManager 124 // Delete ourselves so we don't have to worry about OomPriorityManager
118 // deleting us when we're still working. 125 // deleting us when we're still working.
119 Release(); 126 Release();
120 } 127 }
121 128
122 } // namespace 129 } // namespace
123 130
124 //////////////////////////////////////////////////////////////////////////////// 131 ////////////////////////////////////////////////////////////////////////////////
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 int interval_ms = static_cast<int>(interval.InMilliseconds()); 281 int interval_ms = static_cast<int>(interval.InMilliseconds());
275 // Record time in milliseconds over an interval of approximately 1 day. 282 // Record time in milliseconds over an interval of approximately 1 day.
276 // Start at 100 ms to get extra resolution in the target 750 ms range. 283 // Start at 100 ms to get extra resolution in the target 750 ms range.
277 EXPERIMENT_CUSTOM_COUNTS( 284 EXPERIMENT_CUSTOM_COUNTS(
278 "Tabs.Discard.IntervalTime2", interval_ms, 100, 100000 * 1000, 50); 285 "Tabs.Discard.IntervalTime2", interval_ms, 100, 100000 * 1000, 50);
279 } 286 }
280 // Record Chrome's concept of system memory usage at the time of the discard. 287 // Record Chrome's concept of system memory usage at the time of the discard.
281 base::SystemMemoryInfoKB memory; 288 base::SystemMemoryInfoKB memory;
282 if (base::GetSystemMemoryInfo(&memory)) { 289 if (base::GetSystemMemoryInfo(&memory)) {
283 int mem_anonymous_mb = (memory.active_anon + memory.inactive_anon) / 1024; 290 int mem_anonymous_mb = (memory.active_anon + memory.inactive_anon) / 1024;
291 // TODO(jamescook): Remove this after R25 is deployed to stable. It does
292 // not have sufficient resolution in the 2-4 GB range and has been replaced
293 // by Tabs.Discard.MemAnonymousMB2 below.
284 EXPERIMENT_HISTOGRAM_MEGABYTES("Tabs.Discard.MemAnonymousMB", 294 EXPERIMENT_HISTOGRAM_MEGABYTES("Tabs.Discard.MemAnonymousMB",
285 mem_anonymous_mb); 295 mem_anonymous_mb);
296 EXPERIMENT_CUSTOM_COUNTS("Tabs.Discard.MemAnonymousMB2", mem_anonymous_mb,
297 256, 32768, 50)
286 298
287 int mem_available_mb = 299 int mem_available_mb =
288 (memory.active_file + memory.inactive_file + memory.free) / 1024; 300 (memory.active_file + memory.inactive_file + memory.free) / 1024;
289 EXPERIMENT_HISTOGRAM_MEGABYTES("Tabs.Discard.MemAvailableMB", 301 EXPERIMENT_HISTOGRAM_MEGABYTES("Tabs.Discard.MemAvailableMB",
290 mem_available_mb); 302 mem_available_mb);
303
304 if (memory.gem_size != -1) {
DaveMoore 2012/12/07 18:52:48 If you do this on Intel you will double count memo
James Cook 2012/12/07 19:41:22 Replaced with a MemAllocatedMB stat that tracks bo
305 int mem_graphics_mb = memory.gem_size / 1024 / 1024;
306 EXPERIMENT_HISTOGRAM_MEGABYTES("Tabs.Discard.MemGraphicsMB",
307 mem_graphics_mb);
308 }
291 } 309 }
292 // Set up to record the next interval. 310 // Set up to record the next interval.
293 last_discard_time_ = TimeTicks::Now(); 311 last_discard_time_ = TimeTicks::Now();
294 } 312 }
295 313
296 int OomPriorityManager::GetTabCount() const { 314 int OomPriorityManager::GetTabCount() const {
297 int tab_count = 0; 315 int tab_count = 0;
298 for (BrowserList::const_iterator browser_it = BrowserList::begin(); 316 for (BrowserList::const_iterator browser_it = BrowserList::begin();
299 browser_it != BrowserList::end(); ++browser_it) { 317 browser_it != BrowserList::end(); ++browser_it) {
300 Browser* browser = *browser_it; 318 Browser* browser = *browser_it;
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 content::ZygoteHost::GetInstance()->AdjustRendererOOMScore( 529 content::ZygoteHost::GetInstance()->AdjustRendererOOMScore(
512 iterator->renderer_handle, score); 530 iterator->renderer_handle, score);
513 pid_to_oom_score_[iterator->renderer_handle] = score; 531 pid_to_oom_score_[iterator->renderer_handle] = score;
514 } 532 }
515 priority += priority_increment; 533 priority += priority_increment;
516 } 534 }
517 } 535 }
518 } 536 }
519 537
520 } // namespace chromeos 538 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698