Why default stack size is 1gb?

388 views
Skip to first unread message

taozle

unread,
Jul 24, 2017, 11:32:37 AM7/24/17
to golang-nuts
I found that the default stack size for 64-bit is 1gb, but i can't see any reason for such a large stack, can anyone help me find out the purpose for this?

Jan Mercl

unread,
Jul 24, 2017, 12:56:58 PM7/24/17
to taozle, golang-nuts
On Mon, Jul 24, 2017 at 5:32 PM taozle <zhangl...@gmail.com> wrote:

> I found that the default stack size for 64-bit is 1gb, but i can't see any reason for such a large stack, can anyone help me find out the purpose for this? 

Where did you find that info? AFAICT it's not true. Thread stack size is probably same or similar to the default C stack size on each platform and goroutine stack defaults to few kB only.

--

-j

Florin Pățan

unread,
Jul 24, 2017, 7:33:11 PM7/24/17
to golang-nuts
Iirc the default stack size is 2 or 4 kb not 1 gb. Where did you found the reference?

张李阳

unread,
Jul 24, 2017, 9:51:22 PM7/24/17
to Florin Pățan, golang-nuts
my mistake, i mean the max stack size is 1gb which i saw it here, not the default stack size. Sorry for confusing

On Tue, Jul 25, 2017 at 7:33 AM Florin Pățan <flori...@gmail.com> wrote:
Iirc the default stack size is 2 or 4 kb not 1 gb. Where did you found the reference?

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

T L

unread,
Jul 26, 2017, 10:26:34 AM7/26/17
to golang-nuts, flori...@gmail.com
BTW, I think we do need a GrowCurrentStackTo API, to avoid predicted several stack copies in stack growing.

Jan Mercl

unread,
Jul 26, 2017, 10:37:44 AM7/26/17
to T L, golang-nuts, flori...@gmail.com
On Wed, Jul 26, 2017 at 4:26 PM T L <tapi...@gmail.com> wrote:

> BTW, I think we do need a GrowCurrentStackTo API, to avoid predicted several stack copies in stack growing.

The specification does not requires Go implementations to have any stack at all.

--

-j

T L

unread,
Jul 26, 2017, 12:24:44 PM7/26/17
to golang-nuts, tapi...@gmail.com, flori...@gmail.com

we can just add it in the debug package, just like runtime/debug.SetMaxStack.
 

--

-j

Tyler Compton

unread,
Jul 29, 2017, 5:16:07 PM7/29/17
to T L, golang-nuts, flori...@gmail.com
To be fair, the prerequisites of the language specification aren't nearly as wide as the prerequisites of the entire standard library in general. Implementations like GopherJS are (I think) spec-compliant but don't implement some parts of the standard library due to the constraints of the environment. I'm not necessarily vouching for a GrowCurrentStackTo API, though.

--
Reply all
Reply to author
Forward
0 new messages