perf(editor): bound receipt status work and stabilize timing gates #1078

Closed
kayg wants to merge 0 commits from t3/editor-backlog-performance into dev
Owner

Plan

A 10k receipt backlog retires edits in 4 ms / 64-edit batches, then publishes timestamps by scanning the remaining ledger twice outside that budget. Replace these scans with two indexed minimum heaps: one reference per live edit, an index stored on the existing edit, O(n) space, O(log n) updates inside the bounded drain, O(1) reads. Preserve the receipt authority and MessageChannel scheduling.

The shared-host timing checks also conflate scheduling/GC with work. Warm-up-only experiments still failed (backlog 17/30, tag 2/30; link 0/30). Keep functional correctness and deterministic work bounds in Vitest, and qualify the unchanged 16 ms frame and 2 ms tag budgets in a standalone warmed performance harness on the locked perf VMs. Retain every step, p50/p95/p99 and maximum; frame-blocking maxima remain gated.

failure effect detection and recovery
stale timestamp index wrong pending time shuffled add/remove oracle; positions updated when entries move; retired with their edit
refusal or reconnect during drain pending state must remain honest existing receipt authority tests; cancel tasks as before, retire timestamp only with its edit
scheduler / GC noise wall-time outlier raw wall/thread CPU and same-session dev/dev controls; isolated qualification, no higher budget

Gates: deterministic regression red/green; shuffled timestamp tests; 30 fresh-process passes per requested test on dev+fix via slot/Nix; editor suite and type check; actual SyncClient typing/backlog comparison through perf-turn with both locks and dev/dev controls.

Evidence

Fixes #1074. The root cause combines real unbudgeted ledger scans with shared-host scheduling/GC/JIT noise. Rank product code is unchanged. Vitest now checks functional and deterministic work bounds; the warmed standalone harness keeps the strict 16 ms maximum for every receipt callback and picker, plus the existing rank percentile budgets. No threshold was raised.

  • 25 fresh-process diagnostics and raw step timings: 10,148 callbacks; warming alone did not resolve the backlog/tag flakes.
  • Final-head functional gates: 30/30 per affected test, 565/565 editor tests, heap/status/authority smoke 11/11, editor/perf TypeScript checks, web check 0 errors and 19 warnings. Canonical first-paint brotli is 5 bytes below dev; raw/gzip +77/+86 bytes are disclosed.
  • Locked perf-turn comparison and raw samples: all eight arms qualified, including dev/dev controls. Fix: 42 backlogs / 6,636 callbacks, max 0.855211 ms, receipt p50 about 69% lower, whole backlog CPU 24–27% lower. Link/tag maxima 1.996091/0.573982 ms.
  • Continuous typing CPU confirmation and final closeout: eight counterbalanced arms, each with 120,000 operations after warm-up. Paired CPU -1.06%/-7.55%, paired wall -1.19%/-7.76%; both fix CPU totals lie within the dev-control envelope. No typing regression observed. All deltas, including noisy key maxima, are disclosed. Per-key CPU accounting is too coarse on this VM; the continuous windows resolve that limitation.

Compared head 3d9a055bf55a04c860327af5d5ac4d8656ddafff with pinned dev 437f9ec8923b3d380506f48a77eb11493ef66fb0. All builds/tests used Nix + slot on build VMs; perf used FIFO perf-turn and both perf locks. All own units are inactive and all holds released. Ready for orchestrator review; no merge performed.

## Plan A 10k receipt backlog retires edits in 4 ms / 64-edit batches, then publishes timestamps by scanning the remaining ledger twice outside that budget. Replace these scans with two indexed minimum heaps: one reference per live edit, an index stored on the existing edit, O(n) space, O(log n) updates inside the bounded drain, O(1) reads. Preserve the receipt authority and MessageChannel scheduling. The shared-host timing checks also conflate scheduling/GC with work. Warm-up-only experiments still failed (backlog 17/30, tag 2/30; link 0/30). Keep functional correctness and deterministic work bounds in Vitest, and qualify the unchanged 16 ms frame and 2 ms tag budgets in a standalone warmed performance harness on the locked perf VMs. Retain every step, p50/p95/p99 and maximum; frame-blocking maxima remain gated. | failure | effect | detection and recovery | |---|---|---| | stale timestamp index | wrong pending time | shuffled add/remove oracle; positions updated when entries move; retired with their edit | | refusal or reconnect during drain | pending state must remain honest | existing receipt authority tests; cancel tasks as before, retire timestamp only with its edit | | scheduler / GC noise | wall-time outlier | raw wall/thread CPU and same-session dev/dev controls; isolated qualification, no higher budget | Gates: deterministic regression red/green; shuffled timestamp tests; 30 fresh-process passes per requested test on dev+fix via slot/Nix; editor suite and type check; actual SyncClient typing/backlog comparison through perf-turn with both locks and dev/dev controls. ## Evidence Fixes #1074. The root cause combines real unbudgeted ledger scans with shared-host scheduling/GC/JIT noise. Rank product code is unchanged. Vitest now checks functional and deterministic work bounds; the warmed standalone harness keeps the strict 16 ms maximum for every receipt callback and picker, plus the existing rank percentile budgets. No threshold was raised. - [25 fresh-process diagnostics and raw step timings](https://git.kayg.org/kayg/calternal/issues/1074#issuecomment-91380): 10,148 callbacks; warming alone did not resolve the backlog/tag flakes. - [Final-head functional gates](https://git.kayg.org/kayg/calternal/issues/1074#issuecomment-91501): **30/30 per affected test**, 565/565 editor tests, heap/status/authority smoke 11/11, editor/perf TypeScript checks, web check 0 errors and 19 warnings. Canonical first-paint brotli is 5 bytes below dev; raw/gzip +77/+86 bytes are disclosed. - [Locked perf-turn comparison and raw samples](https://git.kayg.org/kayg/calternal/issues/1074#issuecomment-91546): all eight arms qualified, including dev/dev controls. Fix: 42 backlogs / 6,636 callbacks, max **0.855211 ms**, receipt p50 about 69% lower, whole backlog CPU 24–27% lower. Link/tag maxima 1.996091/0.573982 ms. - [Continuous typing CPU confirmation and final closeout](https://git.kayg.org/kayg/calternal/issues/1074#issuecomment-91817): eight counterbalanced arms, each with 120,000 operations after warm-up. Paired CPU -1.06%/-7.55%, paired wall -1.19%/-7.76%; both fix CPU totals lie within the dev-control envelope. No typing regression observed. All deltas, including noisy key maxima, are disclosed. Per-key CPU accounting is too coarse on this VM; the continuous windows resolve that limitation. Compared head `3d9a055bf55a04c860327af5d5ac4d8656ddafff` with pinned dev `437f9ec8923b3d380506f48a77eb11493ef66fb0`. All builds/tests used Nix + slot on build VMs; perf used FIFO perf-turn and both perf locks. All own units are inactive and all holds released. Ready for orchestrator review; no merge performed.
test(editor): bound status work between receipt drain steps
Some checks failed
CI / server (pull_request) Has been cancelled
CI / rust (pull_request) Has been cancelled
CI / web (pull_request) Has been cancelled
Markdown extraction contract / markdown-native-contract (pull_request) Has been cancelled
Markdown extraction contract / markdown-editor-contract (pull_request) Has been cancelled
f542f1aef3
Author
Owner

validation update, 11 november
#1074 (comment)

x86 1c71b9ba0: 30/30 per affected test, full suite 565/565. type-check corrections and smaller timestamp sifting are pushed. final-head repeat, byte comparison, and locked perf qualification remain pending. no perf holds remain from the cancelled obsolete waiter.

validation update, 11 november https://git.kayg.org/kayg/calternal/issues/1074#issuecomment-91467 x86 1c71b9ba0: 30/30 per affected test, full suite 565/565. type-check corrections and smaller timestamp sifting are pushed. final-head repeat, byte comparison, and locked perf qualification remain pending. no perf holds remain from the cancelled obsolete waiter.
kayg changed title from WIP: bound editor receipt status work and stabilize timing gates to perf(editor): bound receipt status work and stabilize timing gates 2026-11-11 17:27:37 +00:00
Author
Owner

final head 3d9a055bf55a04c860327af5d5ac4d8656ddafff is ready for review. complete root cause, repeat counts, exact commands, final typing comparison, and attached evidence. backlog/link/tag each pass 30/30 fresh processes; full editor 565/565. the primary locked comparison and continuous CPU follow-up show no observed typing/backlog regression. all perf locks released and own units inactive. no merge performed.

final head `3d9a055bf55a04c860327af5d5ac4d8656ddafff` is ready for review. [complete root cause, repeat counts, exact commands, final typing comparison, and attached evidence](https://git.kayg.org/kayg/calternal/issues/1074#issuecomment-91817). backlog/link/tag each pass 30/30 fresh processes; full editor 565/565. the primary locked comparison and continuous CPU follow-up show no observed typing/backlog regression. all perf locks released and own units inactive. no merge performed.
Author
Owner

Merged to dev as 1a14e9f10 (orchestrator, after VM gates: 30/30 per test, editor 565/565, controlled perf). Gated for prod by the next daily train.

Merged to dev as 1a14e9f10 (orchestrator, after VM gates: 30/30 per test, editor 565/565, controlled perf). Gated for prod by the next daily train.
kayg closed this pull request 2026-11-11 17:58:08 +00:00
Some checks failed
CI / server (pull_request) Has been cancelled
CI / rust (pull_request) Has been cancelled
CI / web (pull_request) Has been cancelled
Markdown extraction contract / markdown-native-contract (pull_request) Has been cancelled
Markdown extraction contract / markdown-editor-contract (pull_request) Has been cancelled

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kayg/calternal!1078
No description provided.