Go’s Trace Tooling and Concurrency
summary
A small Go program processes 4,000 RSS-like documents to count a topic and generates a detailed go tool trace (about 1.3 MB trace). The single-thread run takes ~1,000 ms; launching 4,000 goroutines drops to 289 ms but triggers a data race resolved with atomic.AddInt32 and per-goroutine local counters to avoid cache thrash. Switching to a 16-worker pool runs ~388 ms with heavy GC; raising GC budget (e.g. GOGC=1000 → 136 ms) or setting GOMEMLIMIT to 60 MiB restores speed while keeping memory stable.
AI-written summary · about
chapters (9)
- 0:00Analyzing program performance
- 2:58Trace tool overview
- 6:48Implementing concurrency
- 11:44Fixing data races
- 15:31Performance comparison
- 21:27Implementing a worker pool
- 24:25Tuning garbage collection
- 28:47GOMEMLIMIT impact
- 30:53Conclusion
related talks
40mTwo Go programs, three different profiling techniques, all in 40 minutes
36mGolang's Realtime GC in Theory and Practice
40mDebugging concurrency programs in Go
44mGo Profiling and Observability from Scratch
10mGo I made all the mistakes
56mThe Key to Go Efficiency is Just a Few Go Runtime Metrics Away!
21mReaching the ceiling of single-instance Go
18mApplied concurrency in Go
