From 287967f74c9d937b1075a648be5fd9247283cef6 Mon Sep 17 00:00:00 2001
From: Rob Pike
-To make the stacks small, Go's run-time uses segmented stacks. A newly +To make the stacks small, Go's run-time uses resizable, bounded stacks. A newly minted goroutine is given a few kilobytes, which is almost always enough. -When it isn't, the run-time allocates (and frees) extension segments automatically. -The overhead averages about three cheap instructions per function call. +When it isn't, the run-time grows (and shrinks) the memory for storing +the stack automatically, allowing many goroutines to live in a modest +amount of memory. +The CPU overhead averages about three cheap instructions per function call. It is practical to create hundreds of thousands of goroutines in the same -address space. If goroutines were just threads, system resources would +address space. +If goroutines were just threads, system resources would run out at a much smaller number.
@@ -1614,9 +1616,10 @@ it now.Gccgo
's run-time support uses glibc
.
Gc
uses a custom library to keep the footprint under
control; it is
compiled with a version of the Plan 9 C compiler that supports
-segmented stacks for goroutines.
-The gccgo
compiler implements segmented
-stacks on Linux only, supported by recent modifications to the gold linker.
+resizable stacks for goroutines.
+The gccgo
compiler implements these on Linux only,
+using a technique called segmented stacks,
+supported by recent modifications to the gold linker.