llvm-project
7ba4f04e - [Support][Windows] Reserve the thread stack size, don't commit it (#244513)

Commit
1 day ago
[Support][Windows] Reserve the thread stack size, don't commit it (#244513) `llvm_execute_on_thread_impl()` passes the requested stack size to `_beginthreadex()` without `STACK_SIZE_PARAM_IS_A_RESERVATION`. Windows then takes it as the size to commit, so the whole stack of each thread is charged to the process when the thread is created, whether the thread ever uses it or not. clangd asks for 8 MB stacks for its workers, and has one worker per logical processor by default. On a machine with 28 logical processors, an idle clangd has 228 MB of private bytes, and 4 MB with this change. With a project loaded, it has 469 MB instead of 706 MB. The working set is the same, as the memory was never touched. Pass the flag, so that the size is the reservation and the stack is committed as it grows. With a size of 0, the thread gets the default reservation and commit of the executable with or without the flag. Assisted-by: Claude Code
Author
Parents
Loading