~ knotless Search/
↑↓ move↵ open⇧↵ all results

zat.dev/zlay

atproto relay in zig · mirror of https://tangled.org/zat.dev/zlay

0
0
72 lines · 4.2 KB Raw History

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

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.

Measurement256-segment cap, two trials4096-segment cap, two trials
Write ack p500.703–0.736 ms0.101–0.103 ms
Write ack p992.466–2.554 s2.588–2.699 s
Write ack p99.92.828–2.841 s2.966–3.081 s
Write ack max2.870–2.883 s3.009–3.121 s
Scan p994.156–4.234 ms1.585–1.704 ms
Maintenance cycles / compactions106 / 277 / 3
Flush time189–193 ms35–37 ms
Compaction time19.002–19.066 s3.843–3.977 s
Collection time1.172–1.180 s1.033–1.037 s
Longest maintenance cycle2.868–2.881 s3.005–3.117 s
Producer submissions blocked5,106–5,5041,274–1,353
Drain beyond scheduled interval0.86–0.93 ms1.477–1.611 s
Reopen writer and reader45–47 ms78–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 records verified cleanup, source hashes and executable hashes. Raw results, environment, and suite are retained.

The migration gates and asks describe what would need to change before reconsidering this design. No core zkv change or new production default is proposed from this result.