ssd-streaming: opt-in measure mode — per-token page invalidation + true disk-read accounting (Darwin) - #637
Conversation
…true disk-read accounting (Darwin)
|
Validation on this exact branch (M4 Max 128 GB, macOS 26, DeepSeek 4 Flash 91 GB, Inertness (flag unset) — same command on vanilla Enabled ( Logs available on request. |
What
On Darwin, sustained-decode benchmarks of
--ssd-streamingare silently optimistic: the unified page cache serves repeat expert reads from RAM, so on a machine with more RAM than the working set you are measuring the page cache, not the SSD path.This opt-in mode (
DS4_STREAMING_MEASURE_INVALIDATE=1) makes streaming benchmarks honest:msync(MS_INVALIDATE)— the only primitive we found effective on Darwin (madvise(MADV_DONTNEED)and friends are advisory no-ops for this purpose);ri_diskio_bytesreadand per-run read accounting;R = N / (T_decode − T_msync)can be computed.Validation
Measured on M4 Max 128 GB, DeepSeek 4 Flash (91 GB),
--ssd-streaming-cache-experts 39GB, current main (54b36ed): four 1500-token decode runs. Residency at decode start: 0% (verified in-log each run). Disk-read accounting matches cache-miss arithmetic exactly (misses × expert size = bytes pread, to the MiB). The msync-corrected rate is stable across runs whose raw rates differ by ±7% from page-cache state — the correction removes exactly the state-dependent term.One caveat we observed once in four runs: total disk reads ~2.8× the pread bytes in a single run (not reproduced in an identical rerun); we left a note in the accounting docs — happy to discuss.
Why upstream
Anyone benchmarking or optimizing
--ssd-streamingon a Mac needs this to see real I/O. It is opt-in, zero cost when disabled, Darwin-only guarded.