3 ms·
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
by romed 8y ago
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.
- apoorvgarg 8y agoAgain, 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 http://man7.org/linux/man-pages/man3/pthread_create.3.html
- chmaynard 8y agoThe 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.
- hazeii 8y agoOne 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"