
Changelog Master Feed A deep dive into Go's stack (Go Time #288)
5 snips
Aug 11, 2023 In this podcast, the speakers dive deep into how the Go stack works and why programmers should care. They discuss topics such as memory management, the growth and allocation of the stack, the perception of intelligence in the Go community, the use of pointers and structs in Go programming, reordering fields in structures for optimization, and a proposal for arbitrary precision and array bounds checking in Go. They also share amusing anecdotes about printers and express their gratitude to community contributors and listeners.
AI Snips
Chapters
Transcript
Episode notes
Go Stacks Grow Like Relocatable Slices
- Go’s stack behaves like a growable slice, expanding toward lower addresses as calls add stack frames.
- When capacity runs out, Go copies the stack, updates recorded pointers, and later lets garbage collection shrink excess space.
Why Go Cannot Always Move A Stack
- Go uses cooperative preemption at function-entry checks and uncooperative preemption for long-running loops.
- Only clean pointer information permits stack movement, so interrupted loops can be examined but not safely relocated.
Why Go Stacks Grow Downward
- Go follows conventional stack layout, growing from high addresses downward while heap allocations generally grow upward.
- Stack storage may be reused through allocator size classes rather than a dedicated stack-only pool.
