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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/app/chrome_main.h" 5 #include "chrome/app/chrome_main.h"
6 6
7 #include "base/at_exit.h" 7 #include "base/at_exit.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/debugger.h" 9 #include "base/debug/debugger.h"
10 #include "base/i18n/icu_util.h" 10 #include "base/i18n/icu_util.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 // We are only searching for ASCII characters so this is OK. 166 // We are only searching for ASCII characters so this is OK.
167 StringToLowerASCII(&command_line_lower); 167 StringToLowerASCII(&command_line_lower);
168 std::wstring::size_type pos = command_line_lower.find(kChromeHtml); 168 std::wstring::size_type pos = command_line_lower.find(kChromeHtml);
169 return (pos != std::wstring::npos); 169 return (pos != std::wstring::npos);
170 } 170 }
171 171
172 #endif // defined(OS_WIN) 172 #endif // defined(OS_WIN)
173 173
174 #if defined(OS_LINUX) 174 #if defined(OS_LINUX)
175 static void AdjustLinuxOOMScore(const std::string& process_type) { 175 static void AdjustLinuxOOMScore(const std::string& process_type) {
176 const int kMiscScore = 7; 176 // Browsers and zygotes should still be killable, but killed last.
177 #if defined(OS_CHROMEOS) 177 const int kZygoteScore = 0;
178 // On ChromeOS, we want plugins to die after the renderers. If this 178 // This is the lowest score that renderers and extensions start with
179 // works well for ChromeOS, we may do it for Linux as well. 179 // in the OomPriorityManager.
180 const int kPluginScore = 4; 180 const int kRendererScore = 300;
181 #else 181 // We want plugins to die after the renderers.
182 const int kPluginScore = 10; 182 const int kPluginScore = 100;
183 #endif 183 // For "miscellaneous" things, we want them after renderers,
184 // but before plugins.
185 const int kMiscScore = (kPluginScore + kRendererScore) / 2;
stevenjb 2011/08/18 00:20:07 While this is logical, it might be more readable i
184 int score = -1; 186 int score = -1;
185 187
186 if (process_type == switches::kPluginProcess || 188 if (process_type == switches::kPluginProcess ||
187 process_type == switches::kPpapiPluginProcess) { 189 process_type == switches::kPpapiPluginProcess) {
188 score = kPluginScore; 190 score = kPluginScore;
189 } else if (process_type == switches::kPpapiBrokerProcess) { 191 } else if (process_type == switches::kPpapiBrokerProcess) {
190 // Kill the broker before the plugin. 192 // The broker should be killed before the PPAPI plugin.
191 score = kPluginScore + 1; 193 score = kPluginScore + 100;
stevenjb 2011/08/18 00:20:07 nit: const for 100
192 } else if (process_type == switches::kUtilityProcess || 194 } else if (process_type == switches::kUtilityProcess ||
193 process_type == switches::kWorkerProcess || 195 process_type == switches::kWorkerProcess ||
194 process_type == switches::kGpuProcess || 196 process_type == switches::kGpuProcess ||
195 process_type == switches::kServiceProcess) { 197 process_type == switches::kServiceProcess) {
196 score = kMiscScore; 198 score = kMiscScore;
197 } else if (process_type == switches::kProfileImportProcess) { 199 } else if (process_type == switches::kProfileImportProcess) {
198 NOTIMPLEMENTED(); 200 NOTIMPLEMENTED();
201 score = kZygoteScore;
199 #ifndef DISABLE_NACL 202 #ifndef DISABLE_NACL
200 } else if (process_type == switches::kNaClLoaderProcess) { 203 } else if (process_type == switches::kNaClLoaderProcess) {
201 score = kPluginScore; 204 score = kPluginScore;
202 #endif 205 #endif
203 } else if (process_type == switches::kZygoteProcess || 206 } else if (process_type == switches::kZygoteProcess ||
204 process_type.empty()) { 207 process_type.empty()) {
205 // Pass - browser / zygote process stays at 0. 208 // For zygotes and unlabeled process types, we want to still make
209 // them killable by the OOM killer.
210 score = kZygoteScore;
206 } else if (process_type == switches::kExtensionProcess || 211 } else if (process_type == switches::kExtensionProcess ||
207 process_type == switches::kRendererProcess) { 212 process_type == switches::kRendererProcess) {
208 LOG(WARNING) << "process type '" << process_type << "' " 213 LOG(WARNING) << "process type '" << process_type << "' "
209 << "should go through the zygote."; 214 << "should be created through the zygote.";
210 // When debugging, these process types can end up being run directly. 215 // When debugging, these process types can end up being run
211 return; 216 // directly, but this isn't the typical path for assigning the OOM
217 // score for them. Still, we want to assign a score that is
218 // somewhat representative for debugging.
219 score = kRendererScore;
212 } else { 220 } else {
213 NOTREACHED() << "Unknown process type"; 221 NOTREACHED() << "Unknown process type";
214 } 222 }
215 if (score > -1) 223 if (score > -1)
216 base::AdjustOOMScore(base::GetCurrentProcId(), score); 224 base::AdjustOOMScore(base::GetCurrentProcId(), score);
217 } 225 }
218 #endif // defined(OS_LINUX) 226 #endif // defined(OS_LINUX)
219 227
220 void SetupCRT(const CommandLine& command_line) { 228 void SetupCRT(const CommandLine& command_line) {
221 #if defined(OS_WIN) 229 #if defined(OS_WIN)
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 900
893 if (SubprocessNeedsResourceBundle(process_type)) 901 if (SubprocessNeedsResourceBundle(process_type))
894 ResourceBundle::CleanupSharedInstance(); 902 ResourceBundle::CleanupSharedInstance();
895 903
896 logging::CleanupChromeLogging(); 904 logging::CleanupChromeLogging();
897 905
898 chrome_main::LowLevelShutdown(); 906 chrome_main::LowLevelShutdown();
899 907
900 return exit_code; 908 return exit_code;
901 } 909 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698