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

zat.dev/zlay

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

0
0
70 lines · 4.2 KB Raw History
# Million-pair maintenance qualification

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.

The split-reader integration keeps page scans responsive, but this adapter's
write tail is not acceptable evidence for migration. Changing the aggregation
window alone does not address it. This is an index-only result, not a full relay
capacity test.

Each case starts with 1,000,000 pairs and receives 150,000 planned membership
requests over 30 seconds: 5,000/sec, 10% novel, plus 100 varied 100-DID pages/sec.
The bounded ingress queue blocks rather than drops requests. Timing starts at
planned arrival, including source lag and queueing. All four cases completed
without errors and verified 1,015,000 pairs after reopening.

| Adapter | Ack p50 | Ack p99 | Scan p99 | Adapter maintenance total | Longest maintenance |
|---|---:|---:|---:|---:|---:|
| RocksDB default | 0.073 ms | 0.135 ms | 0.199 ms | internal | internal |
| RocksDB synced | 0.427 ms | 5.442 ms | 0.330 ms | internal | internal |
| zkv, no aggregation wait | 0.594 ms | 782.421 ms | 3.781 ms | 10.709 s | 826.053 ms |
| zkv, 1 ms aggregation | 1.476 ms | 769.145 ms | 3.186 ms | 10.574 s | 813.868 ms |

zkv performed 53 and 51 maintenance cycles respectively. The no-wait case filled
the 4,096-entry ingress queue and blocked the producer 13 times. The 1 ms case
reached 4,020 queued requests and took another 473 ms to drain after the planned
arrival interval. Completion of this finite trace does not establish a stable
backlog under sustained load. Owner application cohorts include no-ops and must
not be interpreted as durable commit counts.

RocksDB retains its original concurrent per-request WriteBatch path. Both modes
enable WAL; synced mode additionally requests sync. zkv groups up to 16 requests,
elides existing memberships, and synchronously publishes changed batches with
scheduled flush, compaction and collection. These are equivalent logical
membership operations, not identical physical operations. The default RocksDB
row is not a matched durable-ack control.

## Causal interpretation and next experiment

The adapter serializes maintenance with writes, but independent readers no longer
take that writer mutex. The maintenance maxima and acknowledgement tails are
consistent with queued writes waiting behind maintenance. Aggregate timings do
not prove a per-request attribution; phase timings and longer-tail observations
are still needed.

The adapter currently flushes at 256 unflushed log segments or 4 MiB of memtable
data. zkv compaction merges the selected source level and the entire destination
level. A segment-count trigger can therefore produce small tables and repeatedly
rewrite a much larger resident level. That mechanism follows from the source;
this run did not export table sizes or bytes rewritten, so its contribution is
still a hypothesis.

Before changing core zkv, compare this policy with a bounded, byte-oriented flush
policy using the same trace. Export flush input bytes/segments, phase durations,
actual changed commits, and acknowledgement p99.9/max. Include reader refresh
and restart cost: retaining more log segments can simply move the cost there.
Run enough cycles to include maintenance rather than defer it beyond the timed
window. Preserve the baseline and make any policy change in zlay only.

The VM had two performance CPUs, 4 GiB RAM and a 1 GiB ext4 Fly volume in ORD.
All load ran there; production and heavypad were untouched. The app was deleted
and cleanup verified. See the exported [results](zkv-load/fly-million-window/results.csv),
[source/binary hashes and resource lifecycle](zkv-load/fly-million-window/fly-resources.json),
[suite](zkv-load/fly-million-window/suite.sh),
[environment](zkv-load/fly-million-window/environment.txt), and
[completion log](zkv-load/fly-million-window/progress.txt).