Profiling real-world golang service
summary
Profiles a production Go ad-serving service with pprof CPU+heap and benchmark-driven profiles, finds JSON marshaling as the CPU hotspot and replaces the stdlib encoder with a faster library giving ~4x faster marshaling in benchmarks and removing it from top CPU lists. Changes string-key maps to packed 64-bit integer keys, cutting a 1M-entry map from 442MB to 300MB and saving ~1.5GB at 50M entries, lowering GC STW from ~12ms to ~7ms. Also swaps net/http for a zero-allocation client, reduces allocations ~7x, and meets peak load without buying servers.
AI-written summary · about
chapters (6)
- 0:00Introduction
- 6:07Performance issues
- 10:02Profiling in Go
- 17:04Memory optimization
- 24:31HTTP client allocations
- 30:54Summary
related talks
40mTwo Go programs, three different profiling techniques, all in 40 minutes
45mBoost application performance with profile guided optimization
44mGo Profiling and Observability from Scratch
19mHeap Optimization for Go Systems
26mPractical Memory Profiling
51mObscure Go Optimisations
33mBuilding a Go Profiler Using Go
20mOptimizing Go code without a blindfold
