P6 G5 — branches, merges and WHAT_IF (initial budgets, M1 Pro)¶
Raw output: p6-g5-branches.txt, produced by
cargo run --release -p contextdb-bench --bin branch_bench -- 1000,10000,100000,1000000 1000 300,
three runs on the MacBook Pro M1 Pro (16 GB), nothing else running. The
kernel is in memory (no sync) except the actor measurements, which commit
through ctxd's service with fullfsync.
Budgets (ADR 0013 §11)¶
| Item | Budget | Result |
|---|---|---|
| Fork at 10³–10⁶ revisions | constant time and memory | median 0.29–0.42 µs and 212 B per fork at every size; the largest of 50 (the first, cold) 2.8–142 µs |
WHAT_IF vs the commit it previews |
p95 ≤ 2× | 1.31–1.60× in all 12 cells |
A commit on a branch vs the same commit on main, first (copying) write included |
p95 ≤ 1.2× | interleaved in one kernel: 0.88–1.05 in 11 of 12 cells; one cell 4.09 (run 2, 10⁴), not reproduced in 10 repeats (0.96–1.05, plus one 0.28 where main was the slow side). Against a separate never-forked kernel (the first measurement): 0.95–1.26, one cell above 1.2 (10³, run 1) |
| …with 10⁴ private rules on shared premises | reported | main's commit with the branch's 10⁴ rules vs without, same kernel: 0.96–1.10. main has no invisible neighbours in this representation (§3.1). The branch's own commit propagates into its rules (≈ 1 ms for 1,250 dependents per toggle) |
| Per-branch memory, retained sync-point bytes | reported | see below |
| Write latency with actor-side certificate validation | reported | 10 / 100 certified reads, expect_cert_valid off vs on: off: p50 3.9–4.4 ms, p95 4.9–9.2 ms, p99 6.7–13.1 ms; on: p50 3.2–4.5 ms, p95 5.0–8.5 ms, p99 6.6–12.5 ms; no difference above fsync noise |
The p95 values compared are about 1 µs, near the timer step (≈ 42 ns), so
ratios move by ±0.1 between runs. The first branch-vs-main measurement
compared two kernels and one of 12 cells read 1.26 (1.248 at 10⁴ in an
earlier run); the interleaved measurement in one kernel was added after
that and is the one the bench gates on (p6_g5_kernel_pass: true in runs
1 and 3, false in run 2 because of the 4.09 cell). Both are in the raw
output.
The first write after a fork or merge copies the branch¶
ADR 0013 §3.1 represents each branch as its own database, so the first write to a branch (or to its parent) after a fork, and to either side after a merge, copies that database once:
| Revisions | First write after fork | First write on the branch after a merge | Heap of a merge plus one write per side |
|---|---|---|---|
| 10³ | 0.12–0.15 ms | 0.14–0.19 ms | 1.4 MB |
| 10⁴ | 0.31–0.38 ms | 0.32–0.55 ms | 10.7 MB |
| 10⁵ | 4.6–5.2 ms | 5.5–6.0 ms | 105 MB |
| 10⁶ | 51–111 ms | 181–252 ms | 1.09 GB |
The p95 budgets hold because one copy is one sample in a thousand, but a workload that merges often at 10⁵–10⁶ revisions pays a copy per merge per side. §3.1 names the remedy (the chunked columns of §3 behind the same interface); it is not needed for the budgets and is left for when a real store reaches that size.
Merges after many merges (found by G4, ADR r0.6)¶
Two branches exchanging one fact and merging both ways 2,000 times: the p95 of the first 100 merges 53–55 µs, of the last 100 1.04–1.09 ms (19–20×, linear in the sync points and the data), and the kernel holds 3.2 MB afterwards. Before the r0.6 fixes the last merges took 60 ms and the kernel held 488 MB after 1,500 merges.