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

Unified Diff: chrome/app/chrome_main.cc

Issue 7671033: Changing OOM range to 0, 1000 and tweaking OOM algorithm. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More review changes Created 9 years, 4 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
« no previous file with comments | « base/process_util_linux.cc ('k') | chrome/browser/oom_priority_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/app/chrome_main.cc
diff --git a/chrome/app/chrome_main.cc b/chrome/app/chrome_main.cc
index 98c86799018bb343562f72fa47aef1bbf72797c8..ec048505a48939b4c5d6cfb5a7055c85c71b4542 100644
--- a/chrome/app/chrome_main.cc
+++ b/chrome/app/chrome_main.cc
@@ -173,22 +173,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 ||
@@ -196,19 +205,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";
}
@@ -219,7 +234,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
@@ -534,7 +549,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
« no previous file with comments | « base/process_util_linux.cc ('k') | chrome/browser/oom_priority_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698