v0.2.1 — Reuse Flush Bucket Allocations
Performance Optimizations
P1: Reuse flush bucket allocations and compact buffer in-place
flushNode previously allocated a fresh [][]Message bucket slice and a remaining slice on every flush — producing 85.7% of all heap objects. This release:
- Adds a reusable
flushBucketsfield to internal nodes, reset via[:0]each flush - Compacts the buffer in-place instead of allocating a new
remainingslice
Benchmarks (vs v0.2.0, Apple M2 Max, Go 1.26, -count=6)
| Benchmark | Metric | Before | After | Δ |
|---|---|---|---|---|
| Put/Sequential/1M | sec/op | 139ms | 106ms | -24% |
| Put/Random/1M | sec/op | 1.70s | 1.08s | -36% |
| Put/Random/1M | B/op | 5.5Gi | 55Mi | -99.0% |
| Put/Random/1M | allocs | 11.2M | 4.8K | -99.96% |
| Put/Random/100K | B/op | 200Mi | 5.8Mi | -97% |
| Mixed | B/op | 89Mi | 21B | -100% |
| Delete | B/op | 38.5Mi | 3.3Ki | -99.99% |
| Delete | allocs | 33K | 6 | -99.98% |
Full benchstat comparison in benchmarks/benchstat_v0.2.0...v0.2.1.txt.