summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-30 20:42:27 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-30 20:42:27 +0000
commit57a336aa8b9a591e42fadcae359b20d596af7526 (patch)
tree74c2068e69aaa70c2040e62d8d14dc3583246c2b
parent0003f509cd63c23518dd20e62e871807ae973065 (diff)
downloadchromium_src-57a336aa8b9a591e42fadcae359b20d596af7526.zip
chromium_src-57a336aa8b9a591e42fadcae359b20d596af7526.tar.gz
chromium_src-57a336aa8b9a591e42fadcae359b20d596af7526.tar.bz2
Remove all MemoryModel-related code, since we're unlikely to use it again. Also changes some sample code to use a random generic name ("PruningAlgorithm") instead of MemoryModel in hopes that no one will be confused.
This does not remove IdleTimer, even though it now has no users. I do plan to remove it, but I want to do that in a separate commit so it's easy to reference and revert if at some later point we want this functionality. BUG=none TEST=none Review URL: http://codereview.chromium.org/242079 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27652 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/field_trial.h6
-rw-r--r--base/process.h18
-rw-r--r--base/process_posix.cc15
-rw-r--r--base/process_win.cc71
-rw-r--r--chrome/browser/browser.cc59
-rw-r--r--chrome/browser/browser.h4
-rw-r--r--chrome/browser/browser_process.h17
-rw-r--r--chrome/browser/browser_process_impl.cc13
-rw-r--r--chrome/browser/browser_process_impl.h7
-rw-r--r--chrome/browser/browser_trial.cc5
-rw-r--r--chrome/browser/browser_trial.h2
-rw-r--r--chrome/browser/renderer_host/browser_render_process_host.cc15
-rw-r--r--chrome/common/child_process_info.h1
-rw-r--r--chrome/common/chrome_switches.cc6
-rw-r--r--chrome/common/chrome_switches.h1
-rw-r--r--chrome/test/testing_browser_process.h2
16 files changed, 8 insertions, 234 deletions
diff --git a/base/field_trial.h b/base/field_trial.h
index 82bf3b36..0779981 100644
--- a/base/field_trial.h
+++ b/base/field_trial.h
@@ -22,7 +22,7 @@
//------------------------------------------------------------------------------
// Example: Suppose we have an experiment involving memory, such as determining
-// the impact of memory model command line flags actual memory use.
+// the impact of some pruning algorithm.
// We assume that we already have a histogram of memory usage, such as:
// HISTOGRAM_COUNTS("Memory.RendererTotal", count);
@@ -38,9 +38,9 @@
// int group2 = trial->AppendGroup("_low_mem", 20); // 2% in _low_mem group.
// // Take action depending of which group we randomly land in.
// if (trial->group() == group1)
-// SetMemoryModel(HIGH); // Sample setting of browser state.
+// SetPruningAlgorithm(kType1); // Sample setting of browser state.
// else if (trial->group() == group2)
-// SetMemoryModel(LOW); // Sample alternate setting.
+// SetPruningAlgorithm(kType2); // Sample alternate setting.
// We then modify any histograms we wish to correlate with our experiment to
// have slighly different names, depending on what group the trial instance
diff --git a/base/process.h b/base/process.h
index 459ad58..fa076b9 100644
--- a/base/process.h
+++ b/base/process.h
@@ -66,24 +66,6 @@ class Process {
// Returns true if the priority was changed, false otherwise.
bool SetProcessBackgrounded(bool value);
- // Reduces the working set of memory used by the process.
- // The algorithm used by this function is intentionally vague. Repeated calls
- // to this function consider the process' previous required Working Set sizes
- // to determine a reasonable reduction. This helps give memory back to the OS
- // in increments without over releasing memory.
- // When the WorkingSet is reduced, it is permanent, until the caller calls
- // UnReduceWorkingSet.
- // Returns true if successful, false otherwise.
- bool ReduceWorkingSet();
-
- // Undoes the effects of prior calls to ReduceWorkingSet().
- // Returns true if successful, false otherwise.
- bool UnReduceWorkingSet();
-
- // Releases as much of the working set back to the OS as possible.
- // Returns true if successful, false otherwise.
- bool EmptyWorkingSet();
-
private:
ProcessHandle process_;
size_t last_working_set_size_;
diff --git a/base/process_posix.cc b/base/process_posix.cc
index c9a7dfc..f0e019a 100644
--- a/base/process_posix.cc
+++ b/base/process_posix.cc
@@ -36,21 +36,6 @@ bool Process::SetProcessBackgrounded(bool value) {
return true;
}
-bool Process::ReduceWorkingSet() {
- // http://code.google.com/p/chromium/issues/detail?id=8083
- return false;
-}
-
-bool Process::UnReduceWorkingSet() {
- // http://code.google.com/p/chromium/issues/detail?id=8083
- return false;
-}
-
-bool Process::EmptyWorkingSet() {
- // http://code.google.com/p/chromium/issues/detail?id=8083
- return false;
-}
-
ProcessId Process::pid() const {
if (process_ == 0)
return 0;
diff --git a/base/process_win.cc b/base/process_win.cc
index 263e577..469e7cd 100644
--- a/base/process_win.cc
+++ b/base/process_win.cc
@@ -38,77 +38,6 @@ bool Process::SetProcessBackgrounded(bool value) {
return (SetPriorityClass(process_, priority) != 0);
}
-// According to MSDN, these are the default values which XP
-// uses to govern working set soft limits.
-// http://msdn.microsoft.com/en-us/library/ms686234.aspx
-static const int kWinDefaultMinSet = 50 * 4096;
-static const int kWinDefaultMaxSet = 345 * 4096;
-static const int kDampingFactor = 2;
-
-bool Process::ReduceWorkingSet() {
- if (!process_)
- return false;
- // The idea here is that when we the process' working set has gone
- // down, we want to release those pages to the OS quickly. However,
- // when it is not going down, we want to be careful not to release
- // too much back to the OS, as it could cause additional paging.
-
- // We use a damping function to lessen the working set over time.
- // As the process grows/shrinks, this algorithm will lag with
- // working set reduction.
- //
- // The intended algorithm is:
- // TargetWorkingSetSize = (LastWorkingSet/2 + CurrentWorkingSet) /2
-
- scoped_ptr<ProcessMetrics> metrics(
- ProcessMetrics::CreateProcessMetrics(process_));
- WorkingSetKBytes working_set;
- if (!metrics->GetWorkingSetKBytes(&working_set))
- return false;
-
-
- // We want to compute the amount of working set that the process
- // needs to keep in memory. Since other processes contain the
- // pages which are shared, we don't need to reserve them in our
- // process, the system already has them tagged. Keep in mind, we
- // don't get to control *which* pages get released, but if we
- // assume reasonable distribution of pages, this should generally
- // be the right value.
- size_t current_working_set_size = working_set.priv +
- working_set.shareable;
-
- size_t max_size = current_working_set_size;
- if (last_working_set_size_)
- max_size = (max_size + last_working_set_size_) / 2; // Average.
- max_size *= 1024; // Convert to KBytes.
- last_working_set_size_ = current_working_set_size / kDampingFactor;
-
- BOOL rv = SetProcessWorkingSetSize(process_, kWinDefaultMinSet, max_size);
- return rv == TRUE;
-}
-
-bool Process::UnReduceWorkingSet() {
- if (!process_)
- return false;
-
- if (!last_working_set_size_)
- return true; // There was nothing to undo.
-
- // We've had a reduced working set. Make sure we have lots of
- // headroom now that we're active again.
- size_t limit = last_working_set_size_ * kDampingFactor * 2 * 1024;
- BOOL rv = SetProcessWorkingSetSize(process_, kWinDefaultMinSet, limit);
- return rv == TRUE;
-}
-
-bool Process::EmptyWorkingSet() {
- if (!process_)
- return false;
-
- BOOL rv = SetProcessWorkingSetSize(process_, -1, -1);
- return rv == TRUE;
-}
-
ProcessId Process::pid() const {
if (process_ == 0)
return 0;
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index d340b0e..a4052bd 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -102,58 +102,6 @@ using base::TimeDelta;
// How long we wait before updating the browser chrome while loading a page.
static const int kUIUpdateCoalescingTimeMS = 200;
-// Idle time before helping prune memory consumption.
-static const int kBrowserReleaseMemoryInterval = 30; // In seconds.
-
-///////////////////////////////////////////////////////////////////////////////
-
-// A task to reduce the working set of the child processes that live on the IO
-// thread (i.e. plugins, workers).
-class ReduceChildProcessesWorkingSetTask : public Task {
- public:
- virtual void Run() {
-#if defined(OS_WIN)
- for (ChildProcessHost::Iterator iter; !iter.Done(); ++iter)
- iter->ReduceWorkingSet();
-#endif
- }
-};
-
-// A browser task to run when the user is not using the browser.
-// In our case, we're trying to be nice to the operating system and release
-// memory not in use.
-class BrowserIdleTimer : public base::IdleTimer {
- public:
- BrowserIdleTimer()
- : base::IdleTimer(TimeDelta::FromSeconds(kBrowserReleaseMemoryInterval),
- false) {
- }
-
- virtual void OnIdle() {
-#if defined(OS_WIN)
- // We're idle. Release browser and renderer unused pages.
-
- // Handle the Browser.
- base::Process process(GetCurrentProcess());
- process.ReduceWorkingSet();
-
- // Handle the Renderer(s).
- RenderProcessHost::iterator renderer_iter(
- RenderProcessHost::AllHostsIterator());
- while (!renderer_iter.IsAtEnd()) {
- base::Process process = renderer_iter.GetCurrentValue()->process();
- process.ReduceWorkingSet();
- renderer_iter.Advance();
- }
-
- // Handle the child processe. We need to iterate through them on the IO
- // thread because that thread manages the child process collection.
- g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
- new ReduceChildProcessesWorkingSetTask());
-#endif
- }
-};
-
///////////////////////////////////////////////////////////////////////////////
namespace {
@@ -181,8 +129,7 @@ Browser::Browser(Type type, Profile* profile)
is_attempting_to_close_browser_(false),
cancel_download_confirmation_state_(NOT_PROMPTED),
maximized_state_(MAXIMIZED_STATE_DEFAULT),
- method_factory_(this),
- idle_task_(new BrowserIdleTimer) {
+ method_factory_(this) {
tabstrip_model_.AddObserver(this);
registrar_.Add(this, NotificationType::SSL_VISIBLE_STATE_CHANGED,
@@ -209,10 +156,6 @@ Browser::Browser(Type type, Profile* profile)
encoding_auto_detect_.Init(prefs::kWebKitUsesUniversalDetector,
profile_->GetPrefs(), NULL);
-
- // Trim browser memory on idle for low & medium memory models.
- if (g_browser_process->memory_model() < BrowserProcess::HIGH_MEMORY_MODEL)
- idle_task_->Start();
}
Browser::~Browser() {
diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h
index 8e42694..d881059 100644
--- a/chrome/browser/browser.h
+++ b/chrome/browser/browser.h
@@ -25,7 +25,6 @@
#include "chrome/common/pref_member.h"
#include "testing/gtest/include/gtest/gtest_prod.h"
-class BrowserIdleTimer;
class BrowserWindow;
class DebuggerWindow;
class FindBarController;
@@ -795,9 +794,6 @@ class Browser : public TabStripModelDelegate,
// Dialog box used for opening and saving files.
scoped_refptr<SelectFileDialog> select_file_dialog_;
- // The browser idle task helps cleanup unused memory resources when idle.
- scoped_ptr<BrowserIdleTimer> idle_task_;
-
// Keep track of the encoding auto detect pref.
BooleanPrefMember encoding_auto_detect_;
diff --git a/chrome/browser/browser_process.h b/chrome/browser/browser_process.h
index ff41250..7c1c5b3 100644
--- a/chrome/browser/browser_process.h
+++ b/chrome/browser/browser_process.h
@@ -53,21 +53,6 @@ class BrowserProcess {
BrowserProcess() {}
virtual ~BrowserProcess() {}
- // The browser has 3 memory model configurations. These models have to
- // do with how aggressively we release Renderer memory to the OS.
- // Low memory releases memory the fastest, High memory releases it the
- // slowest. Geek out!
- enum MemoryModel {
- // Will release as much memory as it can after each tab switch, and also
- // after user idle.
- LOW_MEMORY_MODEL,
- // Will release a little memory after each tab switch and also after
- // user idle.
- MEDIUM_MEMORY_MODEL,
- // Hangs onto every last byte.
- HIGH_MEMORY_MODEL
- };
-
// Invoked when the user is logging out/shutting down. When logging off we may
// not have enough time to do a normal shutdown. This method is invoked prior
// to normal shutdown and saves any state that must be saved before we are
@@ -133,8 +118,6 @@ class BrowserProcess {
// Returns the locale used by the application.
virtual const std::string& GetApplicationLocale() = 0;
- virtual MemoryModel memory_model() = 0;
-
DownloadRequestManager* download_request_manager();
// Returns an event that is signaled when the browser shutdown.
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index 1509c68..f381b65 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -146,7 +146,6 @@ BrowserProcessImpl::BrowserProcessImpl(const CommandLine& command_line)
created_debugger_wrapper_(false),
created_devtools_manager_(false),
module_ref_count_(0),
- memory_model_(HIGH_MEMORY_MODEL),
checked_for_new_frames_(false),
using_new_frames_(false),
have_inspector_files_(true) {
@@ -157,18 +156,6 @@ BrowserProcessImpl::BrowserProcessImpl(const CommandLine& command_line)
// Must be created after the NotificationService.
print_job_manager_.reset(new printing::PrintJobManager);
- // Configure the browser memory model.
- if (command_line.HasSwitch(switches::kMemoryModel)) {
- std::wstring model = command_line.GetSwitchValue(switches::kMemoryModel);
- if (!model.empty()) {
- if (model == L"high")
- memory_model_ = HIGH_MEMORY_MODEL;
- else if (model == L"low")
- memory_model_ = LOW_MEMORY_MODEL;
- else if (model == L"medium")
- memory_model_ = MEDIUM_MEMORY_MODEL;
- }
- }
shutdown_event_.reset(new base::WaitableEvent(true, false));
}
diff --git a/chrome/browser/browser_process_impl.h b/chrome/browser/browser_process_impl.h
index 4f094dd..a949ae4 100644
--- a/chrome/browser/browser_process_impl.h
+++ b/chrome/browser/browser_process_impl.h
@@ -183,11 +183,6 @@ class BrowserProcessImpl : public BrowserProcess, public NonThreadSafe {
virtual const std::string& GetApplicationLocale();
- virtual MemoryModel memory_model() {
- DCHECK(CalledOnValidThread());
- return memory_model_;
- }
-
virtual base::WaitableEvent* shutdown_event() {
return shutdown_event_.get();
}
@@ -285,8 +280,6 @@ class BrowserProcessImpl : public BrowserProcess, public NonThreadSafe {
std::string locale_;
- MemoryModel memory_model_;
-
bool checked_for_new_frames_;
bool using_new_frames_;
diff --git a/chrome/browser/browser_trial.cc b/chrome/browser/browser_trial.cc
index 31a2ea0..10ffcda 100644
--- a/chrome/browser/browser_trial.cc
+++ b/chrome/browser/browser_trial.cc
@@ -6,5 +6,6 @@
// The following is a sample of the lines that should be listed here.
-// // A test to determine the impact of using HIGH vs MEDIUM memory models.
-// const wchar_t* BrowserTrial::kMemoryModelFieldTrial = L"memory_model";
+// // A test to determine the impact of kCase1 vs kCase2 pruning algorithms.
+// const wchar_t* BrowserTrial::kPruningAlgorithmFieldTrial =
+// L"pruning_algorithm";
diff --git a/chrome/browser/browser_trial.h b/chrome/browser/browser_trial.h
index cae4dfa..f878a14 100644
--- a/chrome/browser/browser_trial.h
+++ b/chrome/browser/browser_trial.h
@@ -16,7 +16,7 @@ class BrowserTrial {
public:
// The following is a sample line for what should be listed in this file.
- // static const wchar_t* kMemoryModelFieldTrial;
+ // static const wchar_t* kPruningAlgorithmFieldTrial;
private:
DISALLOW_COPY_AND_ASSIGN(BrowserTrial);
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc
index b0ec310..899b3ff 100644
--- a/chrome/browser/renderer_host/browser_render_process_host.cc
+++ b/chrome/browser/renderer_host/browser_render_process_host.cc
@@ -923,21 +923,6 @@ void BrowserRenderProcessHost::SetBackgrounded(bool backgrounded) {
return;
}
}
-
- // Now tune the memory footprint of the renderer.
- // If the OS needs to page, we'd rather it page idle renderers.
- BrowserProcess::MemoryModel model = g_browser_process->memory_model();
- if (model < BrowserProcess::HIGH_MEMORY_MODEL) {
- if (backgrounded) {
- if (model == BrowserProcess::LOW_MEMORY_MODEL)
- process_.EmptyWorkingSet();
- else if (model == BrowserProcess::MEDIUM_MEMORY_MODEL)
- process_.ReduceWorkingSet();
- } else {
- if (model == BrowserProcess::MEDIUM_MEMORY_MODEL)
- process_.UnReduceWorkingSet();
- }
- }
}
// Note: we always set the backgrounded_ value. If the process is NULL
diff --git a/chrome/common/child_process_info.h b/chrome/common/child_process_info.h
index c99b2c0..31b1cb84 100644
--- a/chrome/common/child_process_info.h
+++ b/chrome/common/child_process_info.h
@@ -46,7 +46,6 @@ class ChildProcessInfo {
int id() const { return id_; }
void SetProcessBackgrounded() const { process_.SetProcessBackgrounded(true); }
- void ReduceWorkingSet() const { process_.ReduceWorkingSet(); }
// Returns an English name of the process type, should only be used for non
// user-visible strings, or debugging pages like about:memory.
diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc
index b619517..176eb57 100644
--- a/chrome/common/chrome_switches.cc
+++ b/chrome/common/chrome_switches.cc
@@ -292,12 +292,6 @@ const wchar_t kTabCountToLoadOnSessionRestore[] =
// all memory allocations during the run.
const wchar_t kMemoryProfiling[] = L"memory-profile";
-// Configure Chrome's memory model.
-// Does chrome really need multiple memory models? No. But we get a lot
-// of concerns from individuals about how the changes work on *their*
-// system, and we need to be able to experiment with a few choices.
-const wchar_t kMemoryModel[] = L"memory-model";
-
// By default, cookies are not allowed on file://. They are needed in for
// testing, for example page cycler and layout tests. See bug 1157243.
const wchar_t kEnableFileCookies[] = L"enable-file-cookies";
diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h
index f6cb10d..8774a0f 100644
--- a/chrome/common/chrome_switches.h
+++ b/chrome/common/chrome_switches.h
@@ -100,7 +100,6 @@ extern const wchar_t kEnableExtensionTimelineApi[];
extern const wchar_t kTabCountToLoadOnSessionRestore[];
extern const wchar_t kMemoryProfiling[];
-extern const wchar_t kMemoryModel[];
extern const wchar_t kEnableFileCookies[];
diff --git a/chrome/test/testing_browser_process.h b/chrome/test/testing_browser_process.h
index 22e106b..d105fda 100644
--- a/chrome/test/testing_browser_process.h
+++ b/chrome/test/testing_browser_process.h
@@ -136,8 +136,6 @@ class TestingBrowserProcess : public BrowserProcess {
return *value;
}
- virtual MemoryModel memory_model() { return HIGH_MEMORY_MODEL; }
-
virtual base::WaitableEvent* shutdown_event() {
return shutdown_event_.get();
}