Go Tune Your Memory
summary
Go exposes one tunable: the GOGC environment variable that sets allowed heap growth relative to the last GC and defaults to GOGC=100. Setting GOGC=50 forces GC roughly twice as often and shrinks working set, useful when a service holds a 20 GB stable dataset. Setting GOGC=400 reduces GC frequency and CPU, cutting latency in one proxy case by ~30%. For short lived processes the option GOGC=off can speed up runs by ~20–30% (observed with Go 1.12 and Prometheus heap metrics).
AI-written summary · about
chapters (15)
- 0:00Intro
- 0:51Why care about Garbage?
- 1:56Stack vs Heap
- 3:11GC Tuning Options
- 3:30Go GC Options
- 5:03The Go heap.
- 5:38Allocate some more memory
- 5:58Garbage-Collect!
- 6:25Allocate more memory
- 7:56Garbage collect!
- 11:24Chart it!
- 12:48Situation: large stable data set
- 15:08Situation: small heap, very rapid GC
- 17:22What if we turn off GC completely?
- 18:22Try it out!
related talks
26mRespecting Memory Limits In Go
50mAn insight into Go Garbage Collection
19mHeap Optimization for Go Systems
48mGolang's Garbage
51mEvolving the Go Memory Manager's RAM and CPU Efficiency
30mGo: escape analysis
30mMemory Management in Go: The good, the bad and the ugly
24mAdvancing Go Garbage Collection with Green Tea
