-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce cost of creating process stacks
When spawning a process, we use mmap(2) to set up the memory used for the process' stack. As part of this, we write some data to the start of the stack, such as a pointer to the process itself. This can trigger a page fault when the stack is new, resulting in the kernel committing the first page. This in turn can be rather slow: somewhere between 5 and 10 microseconds, depending on how lucky you are. To work around this, we now reserve a number of stacks per thread upon startup, and we (volatile) write a dummy value to the private data section of the stack. This allows hiding of the cost for the reserved stacks, though depending on the number of processes spawned and how long they stick around one can still run into this cost. Changelog: performance
- Loading branch information
1 parent
33408cb
commit f463691
Showing
2 changed files
with
47 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters