Bug 1785162 - Allow child-process half-stalls to ride the trains r=glandium,gsvelto

The past couple of weeks of crash telemetry indicate that stalling on
OOM in child processes for half as long as in main processes drastically
reduces child process OOM crashes without noticeably increasing
main-process OOM crashes.

Give it a ticket and send it on its way.

Differential Revision: https://phabricator.services.mozilla.com/D158790
This commit is contained in:
Ray Kraesig 2022-10-07 15:40:24 +00:00
Родитель ade3a4205a
Коммит b90e6da27e
1 изменённых файлов: 2 добавлений и 15 удалений

Просмотреть файл

@ -1373,8 +1373,7 @@ static inline void ApplyZeroOrJunk(void* aPtr, size_t aSize) {
} }
} }
// On Windows, delay crashing on OOM. Partly experimental. (See bug 1785145 for // On Windows, delay crashing on OOM.
// more details.)
#ifdef XP_WIN #ifdef XP_WIN
// Implementation of VirtualAlloc wrapper (bug 1716727). // Implementation of VirtualAlloc wrapper (bug 1716727).
@ -1393,19 +1392,14 @@ struct StallSpecs {
static constexpr StallSpecs maxStall = {.maxAttempts = kMaxAttempts, static constexpr StallSpecs maxStall = {.maxAttempts = kMaxAttempts,
.delayMs = kDelayMs}; .delayMs = kDelayMs};
static constexpr StallSpecs doNotStall
[[maybe_unused]] = {.maxAttempts = 0, .delayMs = 0};
Atomic<bool> sHasStalled{false};
static inline StallSpecs GetStallSpecs() { static inline StallSpecs GetStallSpecs() {
# if defined(JS_STANDALONE) # if defined(JS_STANDALONE)
// GetGeckoProcessType() isn't available in this configuration. (SpiderMonkey // GetGeckoProcessType() isn't available in this configuration. (SpiderMonkey
// on Windows mostly skips this in favor of directly calling ::VirtualAlloc(), // on Windows mostly skips this in favor of directly calling ::VirtualAlloc(),
// though, so it's probably not going to matter whether we stall here or not.) // though, so it's probably not going to matter whether we stall here or not.)
return maxStall; return maxStall;
# elif defined(NIGHTLY_BUILD) # else
// On Nightly, partly for experiment's sake (bug 1785162):
//
switch (GetGeckoProcessType()) { switch (GetGeckoProcessType()) {
// For the main process, stall for the maximum permissible time period. (The // For the main process, stall for the maximum permissible time period. (The
// main process is the most important one to keep alive.) // main process is the most important one to keep alive.)
@ -1416,13 +1410,6 @@ static inline StallSpecs GetStallSpecs() {
default: default:
return {.maxAttempts = kMaxAttempts / 2, .delayMs = kDelayMs}; return {.maxAttempts = kMaxAttempts / 2, .delayMs = kDelayMs};
} }
# else
// In the main process, always stall.
if (GetGeckoProcessType() == GeckoProcessType::GeckoProcessType_Default) {
return maxStall;
}
// Otherwise, stall at most once.
return sHasStalled.compareExchange(false, true) ? maxStall : doNotStall;
# endif # endif
} }