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

zat.dev/zlay

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

0
0
77 lines · 4.6 KB Raw History

Allocator parity changes the measured baseline

Paired allocator controls

The earlier ReleaseSafe harness used std.process.Init.gpa, which is SafeAllocator in this installed Zig 0.17.0, even when linked with libc. Production zlay explicitly uses c_allocator. This was a material mismatch for the zkv path. It affected both engines' Zig wrappers, but RocksDB's internal C/C++ allocations did not switch to SafeAllocator.

The corrected harness explicitly chooses the storage and Threaded/zio runtime allocator in both controls. The default is C; --allocator=process selects the ReleaseSafe process allocator. Trace arrays remain in the process arena and are prepared before timing. The corrected result is a production allocator match, not a full-relay capacity measurement or complete runtime configuration match.

Paired result

Two trials of each control ran in reverse order on one disposable Fly VM. Each starts from one million memberships and receives 150,000 planned requests in 30 seconds, 10% novel, plus 100 varied pages/sec. Every request completes, and every trial verifies all 1,015,000 expected pairs after reopen. Both controls retain WAL/durable-publication semantics; RocksDB requests sync. zkv retains duplicate elision, up to 16 grouped requests, no aggregation wait and the 256-segment / 4 MiB maintenance triggers. These match logical work, not physical write batches. Queueing changes grouping, so changed-commit and maintenance counts are reported rather than assumed identical.

Adapter / allocatorWrite ack p50Write ack p99Scan p99Adapter maintenance
RocksDB synced / C0.492–0.506 ms0.775–0.803 ms0.328–0.331 msinternal
RocksDB synced / Safe0.493–0.510 ms0.772–0.818 ms0.331–0.361 msinternal
zkv / C0.367–0.383 ms551.186–552.892 ms3.739–3.815 ms7.761–8.329 s
zkv / Safe156.164–174.014 ms974.928–988.843 ms4.179–4.227 ms13.267–13.441 s

Latency starts at planned arrival. C allocation prevents producer blocking in these trials, though the ingress queue still peaks at 2,938–2,954 requests. SafeAllocator fills the 4,096-entry queue and blocks 2,337–2,414 submissions. The large median difference includes this queueing effect; it is not the cost of one allocation. All planned requests remain included when the producer is blocked. This finite trace does not establish long-run backlog equilibrium.

zkv spends 7.087–7.642 seconds compacting with C allocation, versus 12.584–12.746 seconds with SafeAllocator. It performs 54–55 maintenance cycles and about 14.0k changed commits with C, versus 51 cycles and 13.2k changed commits with SafeAllocator. Those are adaptive grouping differences under the same logical trace. Reopen takes 39–45 ms versus 52–53 ms, with filesystem caches retained. Neither measurement is cold-machine recovery.

Allocator choice materially affected the historical results. It does not by itself remove the write-maintenance tail. The next engine measurements must use explicit consumer allocators and preserve this corrected baseline. No conclusion to abandon zkv follows from either allocator result.

Evidence and limits

Core zkv remains at eca4fd1: the range-compaction candidate is intentionally excluded, isolating allocator choice. The VM had two performance CPUs, 4 GiB RAM and a 1 GiB ext4 volume in ORD. Binaries are ReleaseSafe x86_64-linux-gnu, zio with four executors. This remains an index workload; production novelty, networking, validation, event-log persistence and Postgres are not represented.

Allocation counts and bytes copied, CPU samples, physical reads and hardware cache misses are not inferred from these latency measurements. Separate small allocator-growth instrumentation and generated-code inspection are recorded in the experimental core worktree's docs/allocator-comptime.md. Those are not yet actual zeldi workload qualification.

The manifest contains compiler version, exact source/core and binary hashes, completed-suite status and verified app/volume cleanup. The combined CSV is formed from the union of per-case headers, preserving missing telemetry as empty cells. The raw result-0.csv through result-7.csv files retain each engine's actual header; RocksDB's absent phase counters are not interpreted as zero background work. The suite records order and flags. All load ran inside the disposable VM; production and heavypad were untouched.