Make the default stack size smaller
Chrome's main thread needs a 1.5 MiB stack size in order to avoid stack overflow crashes. However if this is set in the PE file then other threads get this size as well, leading to address-space exhaustion in 32-bit Chrome. For threads that we create we can set the size explicitly but for some OS threads (the spell checker and those in the Windows thread pool) they end up with the 1.5 MiB default set in the PE file. This change tries to control this by setting the default thread size (in the PE file) to 1.0 MiB and then creating and switching to a fiber with a 1.5 MiB stack. This dance wastes 1.0 MiB of address space (for the initial stack that is never used) but then saves 0.5 MiB of address space for every thread that doesn't specify a stack size. At startup time on my laptop there are 13 threads (plus the main thread) with 1.5 MiB stacks, so this change saves 13*0.5 MiB - 1.0 MiB = 5.5 MiB of address space. It is quite likely that the default stack size can be dropped to 0.5 MiB which would save another 7 MiB of address space at startup. Bug: 981238, 1023804 Change-Id: Iabc9d86758a8a9fb77761a5a43a9b11278f4effa Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2425743 Commit-Queue: Bruce Dawson <brucedawson@chromium.org> Reviewed-by:Greg Thompson <grt@chromium.org> Reviewed-by:
Koji Ishii <kojii@chromium.org> Cr-Commit-Position: refs/heads/master@{#813553}
Showing
Please register or sign in to comment