diff options
author | gspencer@google.com <gspencer@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-23 17:58:21 +0000 |
---|---|---|
committer | gspencer@google.com <gspencer@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-23 17:58:21 +0000 |
commit | 03eb9d27a79f876a039ca30eba54d1155ab5500b (patch) | |
tree | 91c377e970b5e117c09f657a01a172e5bf993709 /chrome/app/chrome_main.cc | |
parent | c25c7be488ea694d9173374b985e73a5a6eed867 (diff) | |
download | chromium_src-03eb9d27a79f876a039ca30eba54d1155ab5500b.zip chromium_src-03eb9d27a79f876a039ca30eba54d1155ab5500b.tar.gz chromium_src-03eb9d27a79f876a039ca30eba54d1155ab5500b.tar.bz2 |
Trying again to land OOM priority manager changes.
First landing failed because of an obscure problem with building
linux_shared. This change passes the linux_shared trybot (and
linux and linux_chromeos trybots).
Changing OOM range to 0, 1000 and tweaking OOM algorithm.
With this change, we now use the newer oom_score_adj file (with
fallback to oom_adj when on a system that doesn't support it) so that
we can take advantage of a finer range ([0, 1000] instead of [0, 15]).
Also tweaked the OOM priority manager to prioritize things in a
slightly different order, preferring (even more) not to kill tabs that
the user has currently selected.
Original review: http://codereview.chromium.org/7671033/
BUG=chromium-os:18421, chromium:65009
TEST=Ran on device, observed OOM adj values, forced OOM conditions to
watch kills.
Review URL: http://codereview.chromium.org/7708020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97888 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/app/chrome_main.cc')
-rw-r--r-- | chrome/app/chrome_main.cc | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/chrome/app/chrome_main.cc b/chrome/app/chrome_main.cc index 1979602..a1d635e 100644 --- a/chrome/app/chrome_main.cc +++ b/chrome/app/chrome_main.cc @@ -174,22 +174,31 @@ bool HasDeprecatedArguments(const std::wstring& command_line) { #if defined(OS_LINUX) static void AdjustLinuxOOMScore(const std::string& process_type) { - const int kMiscScore = 7; -#if defined(OS_CHROMEOS) - // On ChromeOS, we want plugins to die after the renderers. If this - // works well for ChromeOS, we may do it for Linux as well. - const int kPluginScore = 4; -#else - const int kPluginScore = 10; -#endif + // Browsers and zygotes should still be killable, but killed last. + const int kZygoteScore = 0; + // The minimum amount to bump a score by. This is large enough that + // even if it's translated into the old values, it will still go up + // by at least one. + const int kScoreBump = 100; + // This is the lowest score that renderers and extensions start with + // in the OomPriorityManager. + const int kRendererScore = chrome::kLowestRendererOomScore; + // For "miscellaneous" things, we want them after renderers, + // but before plugins. + const int kMiscScore = kRendererScore - kScoreBump; + // We want plugins to die after the renderers. + const int kPluginScore = kMiscScore - kScoreBump; int score = -1; + DCHECK(kMiscScore > 0); + DCHECK(kPluginScore > 0); + if (process_type == switches::kPluginProcess || process_type == switches::kPpapiPluginProcess) { score = kPluginScore; } else if (process_type == switches::kPpapiBrokerProcess) { - // Kill the broker before the plugin. - score = kPluginScore + 1; + // The broker should be killed before the PPAPI plugin. + score = kPluginScore + kScoreBump; } else if (process_type == switches::kUtilityProcess || process_type == switches::kWorkerProcess || process_type == switches::kGpuProcess || @@ -197,19 +206,25 @@ static void AdjustLinuxOOMScore(const std::string& process_type) { score = kMiscScore; } else if (process_type == switches::kProfileImportProcess) { NOTIMPLEMENTED(); + score = kZygoteScore; #ifndef DISABLE_NACL } else if (process_type == switches::kNaClLoaderProcess) { score = kPluginScore; #endif } else if (process_type == switches::kZygoteProcess || process_type.empty()) { - // Pass - browser / zygote process stays at 0. + // For zygotes and unlabeled process types, we want to still make + // them killable by the OOM killer. + score = kZygoteScore; } else if (process_type == switches::kExtensionProcess || process_type == switches::kRendererProcess) { LOG(WARNING) << "process type '" << process_type << "' " - << "should go through the zygote."; - // When debugging, these process types can end up being run directly. - return; + << "should be created through the zygote."; + // When debugging, these process types can end up being run + // directly, but this isn't the typical path for assigning the OOM + // score for them. Still, we want to assign a score that is + // somewhat representative for debugging. + score = kRendererScore; } else { NOTREACHED() << "Unknown process type"; } @@ -220,7 +235,7 @@ static void AdjustLinuxOOMScore(const std::string& process_type) { void SetupCRT(const CommandLine& command_line) { #if defined(OS_WIN) -#ifdef _CRTDBG_MAP_ALLOC +#if defined(_CRTDBG_MAP_ALLOC) _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); #else @@ -535,7 +550,7 @@ int RunNamedProcessTypeMain(const std::string& process_type, #endif #if !defined(DISABLE_NACL) { switches::kNaClLoaderProcess, NaClMain }, -#ifdef _WIN64 // The broker process is used only on Win64. +#if defined(_WIN64) // The broker process is used only on Win64. { switches::kNaClBrokerProcess, NaClBrokerMain }, #endif #endif // DISABLE_NACL |