Practical Memory Profiling
summary
Benchmark compares two algorithms: original is ~1100 ns/op with 53 bytes and 2 allocations, rival is ~4× faster with zero allocations. Use go test -bench to measure, write memory profile and inspect with go tool pprof, then run the compiler escape report via -gcflags -m=2 to see why values escape. Fixes remove interface-induced allocations and supply constant slice sizes so profile drops to 1 alloc of 5 bytes and then to zero, while CPU gap narrows to a few hundred nanoseconds.
AI-written summary · about
chapters (4)
related talks
40mTwo Go programs, three different profiling techniques, all in 40 minutes
21mUnderstanding Escape Analysis to Speed Up Your Code
44mGo Profiling and Observability from Scratch
51mObscure Go Optimisations
40mProfiling real-world golang service
14mOptimizing Go code without a blindfold
21mGo Right Ahead! Simple Hacks to Cut Memory Usage by 80&
19mHeap Optimization for Go Systems
