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

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: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/process_util_linux.cc ('k') | chrome/browser/oom_priority_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // The minimum amount to bump a score by. This is large enough that
179 // works well for ChromeOS, we may do it for Linux as well. 179 // even if it's translated into the old values, it will still go up
180 const int kPluginScore = 4; 180 // by at least one.
181 #else 181 const int kScoreBump = 100;
182 const int kPluginScore = 10; 182 // This is the lowest score that renderers and extensions start with
183 #endif 183 // in the OomPriorityManager.
184 const int kRendererScore = chrome::kLowestRendererOomScore;
185 // For "miscellaneous" things, we want them after renderers,
186 // but before plugins.
187 const int kMiscScore = kRendererScore - kScoreBump;
188 // We want plugins to die after the renderers.
189 const int kPluginScore = kMiscScore - kScoreBump;
184 int score = -1; 190 int score = -1;
185 191
192 DCHECK(kMiscScore > 0);
193 DCHECK(kPluginScore > 0);
194
186 if (process_type == switches::kPluginProcess || 195 if (process_type == switches::kPluginProcess ||
187 process_type == switches::kPpapiPluginProcess) { 196 process_type == switches::kPpapiPluginProcess) {
188 score = kPluginScore; 197 score = kPluginScore;
189 } else if (process_type == switches::kPpapiBrokerProcess) { 198 } else if (process_type == switches::kPpapiBrokerProcess) {
190 // Kill the broker before the plugin. 199 // The broker should be killed before the PPAPI plugin.
191 score = kPluginScore + 1; 200 score = kPluginScore + kScoreBump;
192 } else if (process_type == switches::kUtilityProcess || 201 } else if (process_type == switches::kUtilityProcess ||
193 process_type == switches::kWorkerProcess || 202 process_type == switches::kWorkerProcess ||
194 process_type == switches::kGpuProcess || 203 process_type == switches::kGpuProcess ||
195 process_type == switches::kServiceProcess) { 204 process_type == switches::kServiceProcess) {
196 score = kMiscScore; 205 score = kMiscScore;
197 } else if (process_type == switches::kProfileImportProcess) { 206 } else if (process_type == switches::kProfileImportProcess) {
198 NOTIMPLEMENTED(); 207 NOTIMPLEMENTED();
208 score = kZygoteScore;
199 #ifndef DISABLE_NACL 209 #ifndef DISABLE_NACL
200 } else if (process_type == switches::kNaClLoaderProcess) { 210 } else if (process_type == switches::kNaClLoaderProcess) {
201 score = kPluginScore; 211 score = kPluginScore;
202 #endif 212 #endif
203 } else if (process_type == switches::kZygoteProcess || 213 } else if (process_type == switches::kZygoteProcess ||
204 process_type.empty()) { 214 process_type.empty()) {
205 // Pass - browser / zygote process stays at 0. 215 // For zygotes and unlabeled process types, we want to still make
216 // them killable by the OOM killer.
217 score = kZygoteScore;
206 } else if (process_type == switches::kExtensionProcess || 218 } else if (process_type == switches::kExtensionProcess ||
207 process_type == switches::kRendererProcess) { 219 process_type == switches::kRendererProcess) {
208 LOG(WARNING) << "process type '" << process_type << "' " 220 LOG(WARNING) << "process type '" << process_type << "' "
209 << "should go through the zygote."; 221 << "should be created through the zygote.";
210 // When debugging, these process types can end up being run directly. 222 // When debugging, these process types can end up being run
211 return; 223 // directly, but this isn't the typical path for assigning the OOM
224 // score for them. Still, we want to assign a score that is
225 // somewhat representative for debugging.
226 score = kRendererScore;
212 } else { 227 } else {
213 NOTREACHED() << "Unknown process type"; 228 NOTREACHED() << "Unknown process type";
214 } 229 }
215 if (score > -1) 230 if (score > -1)
216 base::AdjustOOMScore(base::GetCurrentProcId(), score); 231 base::AdjustOOMScore(base::GetCurrentProcId(), score);
217 } 232 }
218 #endif // defined(OS_LINUX) 233 #endif // defined(OS_LINUX)
219 234
220 void SetupCRT(const CommandLine& command_line) { 235 void SetupCRT(const CommandLine& command_line) {
221 #if defined(OS_WIN) 236 #if defined(OS_WIN)
222 #ifdef _CRTDBG_MAP_ALLOC 237 #if defined(_CRTDBG_MAP_ALLOC)
223 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); 238 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
224 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); 239 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
225 #else 240 #else
226 if (!command_line.HasSwitch(switches::kDisableBreakpad)) { 241 if (!command_line.HasSwitch(switches::kDisableBreakpad)) {
227 _CrtSetReportMode(_CRT_ASSERT, 0); 242 _CrtSetReportMode(_CRT_ASSERT, 0);
228 } 243 }
229 #endif 244 #endif
230 #endif 245 #endif
231 } 246 }
232 247
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 { switches::kGpuProcess, GpuMain }, 542 { switches::kGpuProcess, GpuMain },
528 { switches::kServiceProcess, ServiceProcessMain }, 543 { switches::kServiceProcess, ServiceProcessMain },
529 544
530 #if defined(OS_MACOSX) 545 #if defined(OS_MACOSX)
531 // TODO(port): Use OOP profile import - http://crbug.com/22142 . 546 // TODO(port): Use OOP profile import - http://crbug.com/22142 .
532 { switches::kProfileImportProcess, ProfileImportMain }, 547 { switches::kProfileImportProcess, ProfileImportMain },
533 { switches::kRelauncherProcess, mac_relauncher::internal::RelauncherMain }, 548 { switches::kRelauncherProcess, mac_relauncher::internal::RelauncherMain },
534 #endif 549 #endif
535 #if !defined(DISABLE_NACL) 550 #if !defined(DISABLE_NACL)
536 { switches::kNaClLoaderProcess, NaClMain }, 551 { switches::kNaClLoaderProcess, NaClMain },
537 #ifdef _WIN64 // The broker process is used only on Win64. 552 #if defined(_WIN64) // The broker process is used only on Win64.
538 { switches::kNaClBrokerProcess, NaClBrokerMain }, 553 { switches::kNaClBrokerProcess, NaClBrokerMain },
539 #endif 554 #endif
540 #endif // DISABLE_NACL 555 #endif // DISABLE_NACL
541 #if defined(OS_POSIX) && !defined(OS_MACOSX) 556 #if defined(OS_POSIX) && !defined(OS_MACOSX)
542 // Zygote startup is special -- see RunZygote comments above 557 // Zygote startup is special -- see RunZygote comments above
543 // for why we don't use ZygoteMain directly. 558 // for why we don't use ZygoteMain directly.
544 { switches::kZygoteProcess, RunZygote }, 559 { switches::kZygoteProcess, RunZygote },
545 #endif 560 #endif
546 }; 561 };
547 562
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 907
893 if (SubprocessNeedsResourceBundle(process_type)) 908 if (SubprocessNeedsResourceBundle(process_type))
894 ResourceBundle::CleanupSharedInstance(); 909 ResourceBundle::CleanupSharedInstance();
895 910
896 logging::CleanupChromeLogging(); 911 logging::CleanupChromeLogging();
897 912
898 chrome_main::LowLevelShutdown(); 913 chrome_main::LowLevelShutdown();
899 914
900 return exit_code; 915 return exit_code;
901 } 916 }
OLDNEW
« 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