News for hackers. Stuff that matters.
Re:Why you can have millions of goroutines but only thousand... by romed on Monday October 08, 2018 @08:52PM (#18172544)
This article is wrong and reflects what appears to be a widely-held belief (practically canon here on HN) that a thread has a fixed-size stack. This is not the case on every operating system! Linux, which I've heard is popular, initially commits one page for a thread stack and continues to add pages until that thread's stack limit is hit. So this statement from which this article draws its conclusion is incorrect:

"each OS thread has its own fixed-size stack."

100% wrong.

Re:Why you can have millions of goroutines but only thousand... by apoorvgarg on Monday October 08, 2018 @09:37PM (#18172733)
Again, all this confusion is due to not being clear about virtual and physical memory. Every OS thread in linux does have a fixed virtual memory size (it is claimed when a thread is created, but this claim is on the virtual memory. This value is fixed at creation time). As you grow your program's conceptual stack in this virtual memory area, you would soon hit new pages of virtual memory, leading to page faults and linux allocating physical memory for you.

From a virtual memory standpoint, every thread would appear to have a fixed size which can be set when you create it. [0]

From a physical memory standpoint, every thread would appear to have a dynamic size (but bounded by the virtual memory size of course).

[0] http://man7.org/linux/man-pages/man3/pthread_create.3.html

Re:Why you can have millions of goroutines but only thousand... by chmaynard on Tuesday October 09, 2018 @05:12AM (#18174373)
The article makes a number of authoritative claims without providing much in the way of references to other more scholarly work. One might characterize it as an opinion piece masquerading as serious analysis. Nevertheless, I found it thought-provoking and I'm learning a lot by reading the comments here.
Re:Why you can have millions of goroutines but only thousand... by hazeii on Tuesday October 09, 2018 @05:51AM (#18174540)
One error I spotted is that at 4kb each, 1GB only gets you 250,000 goroutines (i.e. article is wrong by an order of magnitude). Easy mistake to make, but bad in a comparison article.

FTA: "With 4KB per stack, you can put 2.5 million goroutines in a gigabyte of RAM – a huge improvement over Java’s 1MB per thread"