1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Reader dispatch microcosm
The pinned zio runtime's `blockingIo()` changes how a whole task is scheduled while retaining the filesystem vtable and runtime. This probe compares the same `Probe.read` task on a fiber and on a native blocking worker, with one task outstanding. It is a diagnostic control, not a production read-worker integration.
Each of four fresh databases seeds 8192 pairs and flushes one SST, warms the reader, then performs eight rounds of 32 new durable commits. The measured task refreshes the reader, calls the actual 100-entry pagination API, checks the ordered page, measures an unchanged refresh and verifies the last acknowledged pair. It then closes and reopens the index and verifies all 8448 ordered pairs. Order is fiber, native, native, fiber; C allocator, one zio executor, ReleaseSafe on native macOS. There is no network or concurrent writer during a read.
Per-case medians of eight rounds, in microseconds:
| Dispatch | Refresh after 32 commits | Page after refresh | Unchanged refresh | Complete task |
|---|---:|---:|---:|---:|
| Fiber, first case | 2580 | 100 | 65 | 2795 |
| Native, first case | 954 | 25 | 13 | 1021 |
| Native, reverse case | 979 | 27 | 13 | 1045 |
| Fiber, reverse case | 2693 | 99 | 66 | 2914 |
The page metric includes the pagination API's own unchanged refresh and reader locking, not just iteration. Complete-task time includes dispatch, join and the value/ordering checks. These medians are component observations, not scheduled-arrival tail measurements or relay capacity. Thirty-two new commits per query is a deliberate catch-up case; the previous 10%-novel Fly workload averages fewer changed commits per scan, with larger/more numerous SSTs and concurrent publication/GC.
The result supports checking both per-filesystem-operation dispatch and log catch-up work. Source inspection also found that the serial fallback fetched every key in a geometrically growing log window even after its first missing key. Thirty-two new commits can cause 63 reads. The next core experiment short-circuits only that serial fallback, preserving explicit batch operations.
[Raw data](zkv-load/read-dispatch-native/results.csv), source-file and binary hashes and launch differences are retained. The core was the clean `zkv-maintenance` candidate `b66004b`. The source hashes include the complete harness; its new source file was untracked in the captured diff and is committed alongside this report. All four cases passed their complete reopen oracle. No production files or credentials changed.
```sh
zig build index-read-cost -Dbackend=zio -Doptimize=ReleaseSafe --prefix /tmp/zlay-read-cost
uv run --no-project python scripts/zkv/read_cost.py /tmp/zlay-read-cost/bin/index-read-cost /tmp/new-read-cost-results
```
Use a fresh output directory and run timing checks serially. The runner records launch source hashes; build-time source provenance must be captured separately for larger confirmation runs.
## Serial prefix and bounded-worker screens
The serial-prefix core (`59e8636`) reduces the actual 32-commit catch-up request count from 63 to 33. Its [repeat](zkv-load/read-dispatch-prefix/results.csv) yields fiber refresh medians of 2.47–2.56 ms and native medians of 0.91–0.99 ms. That is a useful request reduction but not a demonstrated major latency gain. The larger dispatch gap persists. Actual zeldi tests and localhost smoke pass against that core.
The optional page owner dispatches only `listReposByCollection` through one native thread using the existing bounded owner implementation. It uses the same reader Db, lock, refresh, retry, pagination and caller buffers. A caller either receives QueueFull/Closed before acceptance or waits uncancelably until its borrowed inputs and outputs are no longer in use. Accepted requests drain before the reader closes. Point and collection-list APIs remain on their existing path. Enable the owner only after the CollectionIndex has a stable address and before concurrent use; the allocator must support worker-thread use, as with the existing write owner. The pilot uses C. The default relay configuration does not enable the page owner.
The focused suite now has 39 passing tests, including full admission, borrowed-buffer completion, close/drain, a missing manifest and successful reads after restoration. The [one-executor scheduling control](zkv-load/page-worker-runtime.csv) holds the read lock for 200 ms. A page-worker read leaves the unrelated timer completing at 11 ms and a write at 2 ms, versus 212 ms for both in the intentionally blocking control. This is a nonblocking control with loose bounds, not a throughput benchmark.
The [native paired load screen](zkv-load/page-worker-native/results.csv) uses the same serial-prefix binary and eight-name GC for both configurations. Only the page owner differs. Two reverse-order trials per workload, 1000 scheduled requests/s and 100 scans/s for three seconds:
This first screen predates a harness correction: final statistics were read after the last reply but before joining the page owner. Its observations are retained as diagnostic data, not qualification. The corrected repeat below takes precedence.
| Workload and dispatch | Write p99, ms | Scan p99, ms |
|---|---:|---:|
| Mixed, fiber | 2.411–2.532 | 3.078–3.189 |
| Mixed, page owner | 2.344–2.427 | 2.630–2.645 |
| Novel, fiber | 2.040–2.125 | 4.883–5.263 |
| Novel, page owner | 2.026–2.225 | 2.991–3.123 |
Write observations overlap. Scan observations favor the worker in this screen, but are native macOS observations with the same synthetic keys and short duration as the earlier microcosms. Each worker case completes 301 pages (warmup plus 300 scheduled reads), records a one-request high water below its 16-request bound, and verifies all pairs after reopen. The full suite and native ReleaseSafe zio relay build pass. Larger matched Fly measurements, resource costs and realistic concurrent RPC saturation remain separate gates.
The [joined-owner repeat](zkv-load/page-worker-native-joined/results.csv) joins the page owner before reading its final counters. All eight cases pass their complete page and reopen oracles:
| Workload and dispatch | Write p99, ms | Scan p99, ms |
|---|---:|---:|
| Mixed, fiber | 2.214–2.694 | 2.841–2.863 |
| Mixed, page owner | 2.334–3.889 | 2.617–3.513 |
| Novel, fiber | 1.834–1.898 | 4.134–4.463 |
| Novel, page owner | 2.137–3.822 | 3.065–3.410 |
The corrected screen is not an overall win: mixed observations overlap, novel scans improve, and novel write tails regress. Do not select the earlier screen's favorable ranges. The native dispatch mechanism warrants a Linux comparison, but enabling this path requires larger evidence of useful read improvement without an unacceptable write or resource tradeoff. An initial Fly run with the pre-join harness was explicitly stopped and its app independently destroyed; it is excluded from qualification.
```sh
uv run --no-project python scripts/zkv/microcosm.py /tmp/index-load /tmp/new-page-worker-results --page-worker
```
## Scheduling-only control
`index-owner-cost` repeats the same owner request at 100 Hz with no storage work. It records deadline-to-start delay, enqueue-to-worker-completion time, completion-to-caller-resumption time and the complete scheduled latency. Two reverse-order trials use Threaded Io, one zio executor and four zio executors. All 1200 requests are checked for exact FIFO execution; both caller task and owner are joined before sampling final state.
In the [native macOS observations](zkv-load/owner-handoff-native/results.csv), Threaded-Io start-delay p99 is 4.77–4.98 ms; zio start-delay p99 is 2.04–2.10 ms. Worker turnaround p99 is 0.026–0.074 ms and caller resumption p99 is 0.018–0.053 ms. These are separate per-phase percentiles and must not be added. The control demonstrates a substantial scheduling floor in this native test environment, rather than storage taking those milliseconds. It neither attributes the OS/runtime cause nor establishes the Linux floor under a relay-like load.
The next read attribution should retain the same phase distinction in actual Linux queries, including refresh and iteration service. The earlier microcosm and the separate Fly comparison measure different scheduling and workload conditions; subtracting the control's percentile from their percentile would be invalid.
```sh
zig build index-owner-cost -Dbackend=zio -Doptimize=ReleaseSafe --prefix /tmp/zlay-owner-cost
uv run --no-project python scripts/zkv/owner_cost.py /tmp/zlay-owner-cost/bin/index-owner-cost /tmp/new-owner-cost-results
```