On Thu, Oct 16, 2014 at 12:49 PM, yao shucai <
yao20...@gmail.com> wrote:
>
> I am doing research on segmented stack mechanisms, and in addition to
> academic papers, I am surveying whether segmented stack mechanism is still
> useful on 64-bit machines. On 64 bit machines, why they don’t just use a
> big enough stack, for example, 1GB or even larger? Are segmented stacks
> only useful for 32 bit machines? Are there other reasons for segmented
> stacks on 64 bit machines?
Since goroutine stacks come from the heap so that they can be garbage
collected when the goroutine exits, reserving large amounts of address
space, while cheap, is not free. When you're running a million
goroutines, using up a million gigabytes of your heap for no real
purpose is definitely not free. Though I suppose that if stacks never
grow then stacks would not need to be in the heap, which would make it
somewhat cheaper.
Note that in Go 1.4 stacks are no longer segmented. Instead they are
copied when they need to grow, and the garbage collector will consider
shrinking them if a large stack is no longer being used.
Ian