Reading the Disruptor in Go: Understanding High-Performance Ring Buffer Design Through Source Code
- Time
- 2026-08-09 13:40 ~ 14:10
- Speaker
- 黃國豪
- Room
- TR214
- Co-write
Abstract
When your Go service starts showing latency spikes, channels are often the first suspect. The mutex inside channel, GC pressure, and false sharing . These costs get amplified in high-throughput scenarios.
The LMAX Disruptor is a classic solution from financial trading systems, but does it actually fit Go? This talk walks through the source code of smarty/go-disruptor together, understanding why the Disruptor is fast and where its boundaries lie in the Go ecosystem.
- Where do channel costs come from? Benchmarks show channel bottlenecks in multi-core environments, building intuition around CPU cache lines, false sharing, and mutex contention.
- Reading the source: core ring buffer design Walking through key files: how sequence.go's cache line padding eliminates false sharing, how sequencer.go's atomic operations replace mutexes, and how producer/consumer gating guarantees ordering without locks.
- The Go Memory Model turning point Go 1.19 formally clarified happens-before semantics for atomic operations, moving smarty/go-disruptor from pre-release to stable. We'll read the source to understand what this guarantee means in practice, and why lock-free Go code before this was standing on shaky ground.
- Where's the boundary: when are channels good enough? Using a betting exchange matching engine evaluation as a case study: a practical decision framework balancing throughput requirements, team maintenance cost, and system complexity.
- Borrowing Disruptor ideas back into Go Even without using the Disruptor, its design principles can improve your Go systems: pre-allocated slices to reduce GC pressure, struct padding to avoid false sharing, ring buffers as fixed-size event queues.
Speaker
黃國豪
我是 Dennis ,一名後端工程師,目前專注在 Datafusion 及分散式系統,程式之餘喜歡打排球。 希望能在開源的世界留下足跡。