Profiling and Optimizing Go Programs
summary
Shows concrete fixes: a slice-backed cache outperforms map until about 6–7 items, mutex contention on gets disappears when switching to a read lock and removing costly defer, a handwritten popcount benchmark disappears without a global sink because the compiler inlines and eliminates it. Demonstrates using pprof and execution tracer, CPU profiler defaults to 100Hz (up to ~500Hz via setprofile rate), block/mutex/heap/mutex profiles, and system tools like perf / BPF and go tool trace to add symbols and labels.
AI-written summary · about
