4 ms·
That was unclear. Yes, 1000 concurrent threads will take stack size * 1000.
by paulddraper 8y ago
That was unclear.
Yes, 1000 concurrent threads will take stack size * 1000.
- masklinn 8y agoThread stacks are reserved, but not allocated up-front (unless you're running on OSv apparently[0]). 1000 concurrent threads will not take stack size * 1000, they'll take used pages * 1000 (with used pages being at least 1) + the kernel overhead of the thread structures. That's trivial to check, even in a high-level language (with its own additional overhead) e.g. spawning 1000 threads in Python on OSX takes ~25MB. OSX uses 512k stacks for non-main threads. [0] https://github.com/cloudius-systems/osv/issues/143 https://github.com/cloudius-systems/osv/issues/143