Skip to content

Commit 7ec3202

Browse files
committed
perf: use ArcSwap in EphemeralFile to eliminate read stalls
Replaces the RwLock<BufferedWriter> with a lock-free ArcSwap<FrozenState> pattern. Problem: Previously, flushing the EphemeralFile to disk held a write lock on the struct. During slow disk IO (10ms - 50ms+), this blocked all concurrent readers (GetPage), causing latency spikes and throughput collapse. Solution: 1. Decouple the 'Frozen' flush buffer from the 'Mutable' tail. 2. Use `arc_swap::ArcSwap` to publish the frozen buffer atomically. Readers access it wait-free. 3. Add `disk_committed_offset` to distinguish between data in the buffer vs. disk, preventing race conditions. 4. Add `writer_lock` to serialize concurrent writers (WAL append-only integrity) without blocking readers. Benchmarks (Local NVMe + Synthetic 50ms Latency): - Read Throughput: ~7.4x improvement (43k -> 323k ops/sec). - Write Throughput: ~1600-2300 MB/s (Comparable to baseline). - Fixes #12172
1 parent 015b1c7 commit 7ec3202

1 file changed

Lines changed: 344 additions & 403 deletions

File tree

0 commit comments

Comments
 (0)