News for hackers. Stuff that matters.
Re:Why you can have millions of goroutines but only thousand... by apoorvgarg on Tuesday October 09, 2018 @01:27AM (#18173541)
Nobody is suggesting that you create a million threads. But to think that it is not possible without TBs of physical memory is a fallacy (for 64-bit machines).

The thread switching costs itself could be prohibitive to performance. IIRC, goroutine switching cost is roughly 1/10th of linux thread switching costs.

Re:Why you can have millions of goroutines but only thousand... by cryptonector on Tuesday October 09, 2018 @01:29AM (#18173548)
It's "possible". If you care about performance, then it's not. Obviously I'm not defining "performance", but you'll know this when you see this. Paging is the kiss of death for performance.
Re:Why you can have millions of goroutines but only thousand... by apoorvgarg on Tuesday October 09, 2018 @01:46AM (#18173599)
Paging has nothing to do with this. When I say 1 MB thread stacks, it means the maximum size of that thread's stack in the virtual address space [0]. Each of these million threads could be using only a few KBs for its stack (out of that 1 MB of stack space). That would imply a few gigs of physical memory => no paging.

[0] http://man7.org/linux/man-pages/man3/pthread_attr_setstacksi...