4 ms·
Agree that that kernel can handle many sleeping threads fine. The main problem with a million threads is that they all take up some fixed memory for stack. 1 MB
by isignal 5y ago
Agree that that kernel can handle many sleeping threads fine. The main problem with a million threads is that they all take up some fixed memory for stack. 1 MB/stack as a rough estimate. Go’s green threads use some kind of dynamic stack implementation to solve this problem. Dynamic stack requires a language specific implementation, for ex, with C pointers it would be difficult. Depending on how python C modules work, a similar solution would be needed to just offload to the kernel.
- akvadrako 5y agoYour threads won't be using 1MB per stack unless you are running deeply recursive algorithms, but then you'll be using lots of CPU. The kernel might allocate that much, but it's just virtual memory.