# Flush policy does not resolve the write tail These historical latency measurements used `std.process.Init.gpa`, which is SafeAllocator in this Zig 0.17 ReleaseSafe build, rather than production zlay's explicit `c_allocator`. Both engines' Zig wrappers used it, while RocksDB's internal C++ allocations followed its own allocator path. Treat the timings as harness-specific diagnostics until the allocator-parity rerun is analyzed; they are not a production-matched latency result. Raw observations are retained. ![Paired write latency and maintenance time](zkv-load/fly-flush-policy/comparison.svg) Raising the pilot's flush segment cap from 256 to 4,096 reduces repeated compaction work, but leaves multi-second write stalls. Do not select this change as a migration fix or continue capacity sweeps with the same maintenance design. Four trials ran in order 256, 4096, 4096, 256 on one disposable Fly VM. Each recreated the same million-pair seed using the baseline policy, then applied the selected cap only to the timed phase. The 4 MiB memtable bound remained in both policies. Each trial planned 300,000 membership requests over 60 seconds, 10% novel, alongside 100 varied 100-DID scans/sec. All requests completed without errors, and all 1,030,000 expected pairs verified after reopen. | Measurement | 256-segment cap, two trials | 4096-segment cap, two trials | |---|---:|---:| | Write ack p50 | 0.703–0.736 ms | 0.101–0.103 ms | | Write ack p99 | 2.466–2.554 s | 2.588–2.699 s | | Write ack p99.9 | 2.828–2.841 s | 2.966–3.081 s | | Write ack max | 2.870–2.883 s | 3.009–3.121 s | | Scan p99 | 4.156–4.234 ms | 1.585–1.704 ms | | Maintenance cycles / compactions | 106 / 27 | 7 / 3 | | Flush time | 189–193 ms | 35–37 ms | | Compaction time | 19.002–19.066 s | 3.843–3.977 s | | Collection time | 1.172–1.180 s | 1.033–1.037 s | | Longest maintenance cycle | 2.868–2.881 s | 3.005–3.117 s | | Producer submissions blocked | 5,106–5,504 | 1,274–1,353 | | Drain beyond scheduled interval | 0.86–0.93 ms | 1.477–1.611 s | | Reopen writer and reader | 45–47 ms | 78–79 ms | Latency includes lag from the original planned arrival, not merely time inside an engine call. All trials reached the 4,096-entry ingress bound. Retaining more log segments improved typical write and scan latency, but did not remove the large queued-write interruption. Reopen was also slower. These reopen timings reuse the filesystem cache; they are not cold-machine recovery measurements. The baseline flushed roughly 3.18 MB of logical memtable allocation across 106 cycles, about 30 KB/cycle on average. The larger cap flushed roughly 3.08 MB across seven cycles. Those are memtable bytes, not SST or physical disk bytes. The engine merges the selected source level and the entire destination level; the phase counters confirm that compaction dominates the baseline's maintenance cost. A higher flush threshold avoids many merges but still exposes the longest merge synchronously to waiting writers. Natural grouping changes with queue pressure: the baseline made about 27.2k changed commits, versus 29.5k with the larger cap. The logical membership trace, durable acknowledgement contract and post-reopen oracle match; physical batches are adaptive rather than held identical. The counters do not isolate filesystem cache misses, actual bytes rewritten, or per-request compaction overlap. This experiment therefore establishes policy sensitivity and remaining stalls, not a complete cost model or a full-relay throughput limit. All load ran inside the VM: two performance CPUs, 4 GiB RAM, a 1 GiB ext4 volume in ORD, ReleaseSafe Linux binaries and zio with four executors. No upstream feed, production service or heavypad load was used. The disposable app and volume were deleted; the [manifest](zkv-load/fly-flush-policy/fly-resources.json) records verified cleanup, source hashes and executable hashes. Raw [results](zkv-load/fly-flush-policy/results.csv), [environment](zkv-load/fly-flush-policy/environment.txt), and [suite](zkv-load/fly-flush-policy/suite.sh) are retained. The [migration gates and asks](zkv-zlay-asks.md) describe what would need to change before reconsidering this design. No core zkv change or new production default is proposed from this result.