Commit 24a8a2eb authored by Bruce Dawson's avatar Bruce Dawson Committed by Commit Bot

Reduce stack sizes for 32-bit Chrome

32-bit Chrome continues to hit out-of-memory crashes. Some of these are
presumed to be out-of-address-space crashes which are particularly easy
to hit when running on 32-bit Windows where 32-bit Chrome will only get
2 GiB of address space.

This change lowers the default stack size for Chrome to 0.5 MiB. This
will not affect Chrome's main thread (it uses a fiber to create a larger
stack) but it will affect Windows thread pool worker threads and a few
other threads that we do not directly control.

This change also lowers the stack size for threads that Chrome creates,
but to minimize risk this is only done when running on 32-bit Windows,
where the risk of running out of address space is most severe.

This has been seen to save 25 MiB of address space (50 threads going
from 1 MiB to 0.5 MiB).

Bug: 981238, 1023804
Change-Id: Ia7fc03e0d4b79550cb67cb491892beaae08d5c0d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2461589Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#816653}
parent 462f7264
......@@ -142,7 +142,18 @@ bool CreateThreadInternal(size_t stack_size,
// |chrome/BUILD.gn|, but keep the default stack size of other threads to
// 1MB for the address space pressure.
flags = STACK_SIZE_PARAM_IS_A_RESERVATION;
stack_size = 1024 * 1024;
static BOOL is_wow64 = -1;
if (is_wow64 == -1 && !IsWow64Process(GetCurrentProcess(), &is_wow64))
is_wow64 = FALSE;
// When is_wow64 is set that means we are running on 64-bit Windows and we
// get 4 GiB of address space. In that situation we can afford to use 1 MiB
// of address space for stacks. When running on 32-bit Windows we only get
// 2 GiB of address space so we need to conserve. Typically stack usage on
// these threads is only about 100 KiB.
if (is_wow64)
stack_size = 1024 * 1024;
else
stack_size = 512 * 1024;
#endif
}
......
......@@ -204,13 +204,13 @@ if (!is_android && !is_mac) {
]
if (current_cpu == "x86") {
# Set the initial stack size to 1MiB, instead of the 1.5MiB needed by
# Set the initial stack size to 0.5MiB, instead of the 1.5MiB needed by
# Chrome's main thread. This saves significant memory on threads (like
# those in the Windows thread pool, and others) whose stack size we can
# only control through this setting. Because Chrome's main thread needs
# a minimum 1.5 MiB stack, the main thread (in 32-bit builds only) uses
# fibers to switch to a 1.5 MiB stack before running any other code.
ldflags = [ "/STACK:0x100000" ]
ldflags = [ "/STACK:0x80000" ]
} else {
# Increase the initial stack size. The default is 1MB, this is 8MB.
ldflags = [ "/STACK:0x800000" ]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment