Go now stack allocating objects with size < 32 bytes

88 views
Skip to first unread message

Alexander Shopov

unread,
Jan 6, 2026, 8:52:26 AM (2 days ago) Jan 6
to golang-nuts
Hi all,

Does anyone know whether and if at all there was an announcement that Go now stack allocates objects with size < 32 bytes? I read the 1.25/1.24 Release notes but if it is there I am missing something obvious.

This questions is based on this talk from the last GopherCon: 

NL GopherCon 2025: Understanding Escape Analysis to Speed Up Your Code - Bill Kennedy: https://www.youtube.com/watch?v=FUm0pfgWehI&t=974s
(16m15s):

I believe it is Keith Randall answering - but the answer is that now values smaller than 32 bytes are stack allocated (provided escape analysis agrees).

There is also another reply from the room about why a particular value is escaping. Any info on that would be helpful.

Kind regards:
al_shopov

Keith Randall

unread,
Jan 6, 2026, 11:01:19 AM (2 days ago) Jan 6
to Alexander Shopov, golang-nuts
https://go.dev/doc/go1.25#faster-slices

To be pedantic, Go has allocated objects on the stack since forever. The new thing is the backing store for slices with non-constant sizes.

There's more of this ilk coming, for example https://go-review.googlesource.com/c/go/+/707755

Bill Kennedy

unread,
Jan 6, 2026, 12:46:11 PM (2 days ago) Jan 6
to Alexander Shopov, golang-nuts
There was no announcement or any documentation on this change. The change was to add a 32 byte buffer on the stack that can be used in these situations where the actual allocation determined at runtime is 32 bytes or less.

Yes, this took me by surprise. Hahahaha
Reply all
Reply to author
Forward
0 new messages