4 ms·
The point is that each stack need to be big enough for the worst case. That means it does not really scales to start many thousands of threads. While the future
by varajelle 6y ago
The point is that each stack need to be big enough for the worst case. That means it does not really scales to start many thousands of threads. While the futures themselves used in async code can be kept relatively small, as they only need to contain the state needed while awaiting.
- gpderetta 6y agoIn theory a smart enough OS (or runtime) should be able to reclaim any memory beyond the stack pointer (plus redzone) at any time without preserving its content and shrink back the stack. Because of signal handlers that memory is to be considered volatile anyway. It might not be worth doing it in practice, but it is something to keep on mind.