Mail P1b: search save-log token and paged reconcile #1011

Open
kayg wants to merge 54 commits from t3/paged-search-reconcile-final into dev
Owner

Rethink after the 2026-11-07 follow-up review

The review found that the legacy-cursor path scanned pages to find the final page, then checked only that page. A pre-fence cursor can already cover a stale notes.saved entry several pages earlier, so this tail check cannot prove the whole cursor safe. The generation fence for new receipts remains unchanged; legacy cursor recovery is revised below.

The implementation review found that ordinary room saves publish notes.saved through a separate path from Home executor actions. Both paths now attach the accepted per-note History version to the event and publish the same version with the accepted source. Room saves reuse the already durable Room.version; the version rides on the existing live_meta generation commit, with no added file read, wait, or fsync. The ordinary_room_save_receipt_matches_published_source_version regression proves that the receipt and provider agree.

Perf run note for 2026-11-08

The perf VMs require a password for sudo, so the measurement user cannot run calternal-perf --drop-caches. The dev/dev and candidate/dev samples therefore use identical warm page-cache conditions. cold.startup measures a fresh unindexed Home with warm file pages; it does not qualify cold page-cache I/O. search.catch_up still compares the candidate's token catch-up with dev's full reconcile.

Revised restart path

  • A current cursor with persisted page-start metadata is validated by Engine::position; the indexer re-reads its last journal page and checks each known source generation before trusting the cursor.
  • A cursor without page-start metadata is wholly untrusted. The indexer runs one full paged reconcile and scans retained save receipts from the oldest retained row through the captured head, so no earlier receipt is skipped. It uses the legacy token only as the use-score replay start, then publishes current documents, use scores, and the head token atomically. It does not upgrade legacy cursor metadata after checking only the tail.
  • The legacy reconcile is read-side only. It uses at most 256 journal entries, 256 provider rows, 64 document fetches, 512 compare metadata records, and a 2,000 KiB SQLite writer cache with fence state in a temporary file. Memory stays bounded by those page and batch caps; temporary disk is O(S) for changed rows and fences.
  • Normal current-cursor startup remains incremental: O(K log K + R + D) time and O(256 + R + 64) memory. The one-time legacy repair costs O(K + N log M + M) time, matching the existing full paged path, with bounded memory. Later starts use the normal incremental path.
  • If migration crashes before publish, the old cursor and index stay in place and the next start repeats the full reconcile. Notes saves do not change.
Failure Effect Detection Recovery Test
Legacy cursor has a raced receipt outside its final journal page A tail-only check would leave stale text searchable Missing page-start metadata triggers a receipt scan from the oldest retained row; unknown receipts are re-read from a pinned provider snapshot Full paged reconcile; atomically publish documents and cursor after receipt and snapshot validation legacy_stale_receipt_before_final_page_forces_paged_reindex
Ordinary room-save receipt lacks source_version The indexer cannot compare the receipt with the exact published Notes generation The real-save test compares journal and provider versions New room saves encode Room.version and publish it with live_meta; older versionless receipts stay on the unknown re-read path ordinary_room_save_receipt_matches_published_source_version
Crash during legacy reconcile No mixed documents/cursor become visible Reconcile has not committed Retry the full paged reconcile on restart Legacy stale-receipt recovery and page-boundary kill/restart tests

This one-time legacy path can take as long as today's full reconcile because its old checkpoint carries no proof of which earlier pages were verified. The performance table will separate this compatibility repair from current-cursor startup and report both against the same-epoch control.

Design after the 2026-11-07 generation-fence ruling

P1b stays a shared, backend-only search change. Notes remains the current provider; Mail can use the same cursor and page API later. Notes search, save behavior, result order, and UI stay unchanged. The indexer owns the fence: it will not index a source older than a notes.saved receipt or checkpoint past that receipt.

Fence and restart rules

History::install_executor already returns the accepted per-note version. Append that value as source_version to each new notes.saved event (at most 37 serialized bytes including its comma). Publish the same version with the accepted Notes source and expose it to search. Existing events without the field are unknown: read the item again from a fresh pinned Notes generation, compare its source stamp, and validate the snapshot before checkpointing.

When a journal page touches an item, compare every saved version in that page with the published source version. If the source is behind, drop the private page stage, keep the previous cursor, and park the entry. Subscribe to the existing MetaDb.populated watch before pinning the provider snapshot; its publication notification retries the same page without a polling loop. If the watch produces no notification, allow five bounded exponential-backoff rereads (10, 20, 40, 80, 160 ms), then wait on the watch. A still-pending entry never advances the cursor.

Every commit covers a contiguous run of verified entries, with documents, use scores, and the page token in one SQLite transaction. On startup, validate a current cursor and re-read the final journal page before trusting it. Store that page's starting token beside each new cursor. A legacy cursor without that metadata cannot identify which earlier receipts may have raced, so treat it as wholly untrusted and run a full paged provider reconcile. Publish the verified documents, use scores and current cursor together; a crash leaves the legacy cursor untrusted and the reconcile repeats.

A missing or expired cursor does a full paged reconcile. Before publishing its head token, scan the retained journal through that head and stage the latest per-item fence in SQLite's temporary file. Compare each provider page against those fences; a pending source drops the whole private reconcile. A restored or truncated log is detected only through the engine contract: P1b uses Engine::position and Engine::journal; #928 remains the only owner of signed token proof and high-water restore detection. P1b does not read the high-water file or add/parse token formats. If #928 lands first, rebase and keep this API boundary.

Sizes and cost

Work Bound Cost
Incremental catch-up 256 journal entries; 1,024 related IDs; 64 document payloads O(K log K + R + D); memory O(256 + R + 64)
Cursor-tail recheck for a current cursor 256 entries; one provider page O(256 + D) time and memory
One-time legacy cursor repair Same page, fetch, SQLite cache and disk-fence caps as full reconcile O(K + N log M + M) time, bounded memory
Full reconcile 256 provider rows; 64 document payloads; 512 compare metadata records; fence state in SQLite temp_store=FILE, 2,000 KiB writer cache O(K + N log M + M) for K journal entries, N provider rows, M indexed rows; RAM independent of Home size; temp disk O(S) for changed rows and per-item fences
Version metadata ≤37 serialized bytes per event and accepted-source row At most 37 MB raw for 1M fully versioned rows, before SQLite page overhead; no extra fsync or save-path read

No page uses OFFSET or retains a Home-sized vector. The version is returned by the existing history install; Notes does no extra work on the notes-save path beyond encoding the appended field.

Failure table

Failure Effect Detection Recovery Test
notes.saved is visible before source publication The old source cannot enter the index and the cursor stays before the receipt Published source version is below the event version Drop the page, wait on the existing publication watch, retry the same page Real Notes executor delayed-publication race, incremental and missing-index cases
Crash after receipt, before source publication Receipt remains; cursor cannot pass it Restart replays the durable executor record and rechecks the receipt version Recovery publishes source; index resumes from the prior cursor Crash/restart between journal receipt and publication
Crash or kill at a page boundary Private stage is discarded; committed documents and cursor agree Reopen index and inspect the saved cursor Replay the uncommitted page kill_restart_at_every_provider_page_boundary_converges
Legacy cursor lacks page-start metadata A stale save may be older than the final journal page, so a tail-only check can miss it Missing page-start metadata identifies the legacy cursor Treat the cursor as untrusted and run a full paged reconcile before publishing any cursor legacy_stale_receipt_before_final_page_forces_paged_reindex
Cursor came from a restored older backup Engine cannot prove it against the restored log Engine::position returns SyncTokenExpired Full paged reconcile; never construct a token locally Restored-backup cursor test; #928 owns token-proof coverage
Cursor is ahead or behind Ahead/expired cursor cannot be used; retained behind cursor needs only its tail pages position result plus page sequence checks Full reconcile if expired; otherwise apply bounded pages ahead_cursor_reindexes_from_current_head, valid_behind_cursor_uses_pages_without_listing
Save log is truncated or index is missing No trusted checkpoint remains position/page read expires, or cursor is absent Full paged reconcile with disk-backed fences and one atomic publish truncated_log_reindexes_from_pages, missing_index_rebuilds_in_pages
Publication notification is absent or the snapshot changes No unverified page becomes visible Bounded fallback retry; provider snapshot validation Retry after a notification/backoff or discard and start a fresh reconcile Watch and snapshot-change cases in the generation property test

Tests

  • Ordinary room save: edit and save a real Note, then prove the receipt version matches the published Notes source version.

  • Real Notes race: pause EventRecorder::record_once after the durable receipt and before it returns to BatchPublished; run incremental catch-up and missing-index reconcile; prove neither indexes the old text nor passes the cursor; release publication, restart the indexer, and prove the new text is indexed.

  • Crash before publication: stop after the receipt, reopen Notes so executor recovery replays it, and prove the cursor never skips the entry.

  • Reopen after every journal/provider page boundary and compare the final index to a clean build. A legacy cursor without page-start metadata must also repair a stale receipt more than 256 entries before the cursor.

  • Property test over save versions, delayed/reordered publication notifications, duplicate touches, arbitrary page cuts, and restarts; assert one indexed row per item, latest text, and a cursor no later than the contiguous verified prefix.

  • Restored-older-backup cursor, cursor ahead/behind, truncated log, missing index, and 1M-entry paged reconcile with a 256-row maximum and bounded memory.

Gates

Gate Exact command or run Pass condition
Format CARGO_BUILD_JOBS=4 CARGO_INCREMENTAL=0 ~/bin/slot /nix/var/nix/profiles/default/bin/nix develop -c bash -c 'cd /home/claude/Developer/Worktrees/mail-p1b-test-e0fc && cargo fmt --check' Pass
Clippy CARGO_BUILD_JOBS=4 CARGO_INCREMENTAL=0 ~/bin/slot /nix/var/nix/profiles/default/bin/nix develop -c bash -c 'cd /home/claude/Developer/Worktrees/mail-p1b-test-e0fc && cargo clippy --workspace --all-targets -- -D warnings' Pass
Rust tests CARGO_BUILD_JOBS=4 CARGO_INCREMENTAL=0 ~/bin/slot /nix/var/nix/profiles/default/bin/nix develop -c bash -c 'cd /home/claude/Developer/Worktrees/mail-p1b-test-e0fc && cargo test --workspace --no-fail-fast' Pass
Crash-typing flake cargo test -p calternal --test notes_crash_typing kill_nine_while_people_type_loses_and_doubles_nothing -- --exact 20 candidate and 20 dev runs interleaved; report both pass rates
Chromium Notes search/save, 1440 and 390 ~/bin/slot /nix/var/nix/profiles/default/bin/nix develop -c bash -c 'cd /home/claude/Developer/Worktrees/mail-p1b-test-e0fc/apps/web && CALTERNAL_BIN=/home/claude/Developer/Worktrees/mail-p1b-test-e0fc/target/debug/calternal bunx playwright test e2e/search-palette.spec.ts e2e/search-corpus.spec.ts e2e/editor.spec.ts e2e/list-catch-up.spec.ts --project=chromium-1440 --project=chromium-390 --workers=1' Pass
WebKit Notes search/save, 1440 and 390 ~/bin/slot /nix/var/nix/profiles/default/bin/nix develop -c bash -c 'cd /home/cua/Developer/Worktrees/mail-p1b-webkit-b822165c6/apps/web && CALTERNAL_BIN=/home/cua/Developer/Worktrees/mail-p1b-webkit-b822165c6/target/debug/calternal bunx playwright test e2e/search-palette.spec.ts e2e/search-corpus.spec.ts e2e/editor.spec.ts e2e/list-catch-up.spec.ts --project=webkit-1440 --project=webkit-390 --workers=1' Pass
Perf Hold ~/bin/perf-lock on perf-01 then perf-02 for the complete same-epoch session. Run dev-vs-dev control and candidate/dev ABAB ×5; each sample runs calternal-perf --bin "$SERVER_BIN" --work "$WORK" --data-dir "$DATA" --state-dir "$STATE" --budgets perf/budgets.json --sizes 100k,1000000 --runs 1 --cold-runs 1 --idle-secs 0 --json "$OUT/run.json" --md "$OUT/run.md" and storage-bench save --dir "$SAVE_DIR" --saves 200. Compare first query, query, catch-up, notes-save p50/p99, typing, and startup at 100k/1M beyond the dev-vs-dev spread. Every path is flat or better. The 1M reconcile must beat today's full path or the PR records the measured reason it does not.

Any regression beyond the control spread blocks qualification. Post commands, rates, all metric deltas, and the same-epoch control in PR comments. Never merge.

Design note: the indexer never waits forever on a receipt fence (liveness fix, 2026-11-09)

Problem. Search holds a save receipt back until the provider has published the version the receipt names (the "fence"). If that version is never published, PublicationWait::retry waits on the publication signal with no limit, and the full rebuild enforces the same fences, so it waits too. Search then reports indexing: true for ever. Seen on compute02 and perf-01 with the gap stage (idle server, DIAG waiting for publication signal).

"Receipt ahead of provider". A receipt for item X names source version N (SourceFence::Known(N)), but the provider's published document for X has version M < N (or none), and no further publication arrives. Real ways to get there: a Home restored from an older backup, or note history rebuilt, while the save-log keeps its receipts.

The cap. Options::publication_cap, default 30 s, counted as time stuck on one page: it starts at the first reread for that page, restarts when the page is staged, and is not extended by publication signals for other items (so steady typing elsewhere cannot keep it alive). Tests set it to milliseconds.

After the cap (both places). One relaxed attempt for that page or rebuild, using the same pinned provider snapshot:

  • journal path (catch_up_to, recheck_cursor_tail, apply_live_batch): the page is staged without its Known fences;
  • rebuild path (reconcile_pages): the attempt ignores comparison.pending, passes no fences to the refresh, and skips has_unseen_known_fence.
    The receipt is superseded: the provider's current document is indexed, the cursor advances, indexing goes false. One WARN per pass names the provider and the time waited, and the process-wide counter calternal_search::fences_superseded() goes up by one per relaxed page or rebuild. Relaxing lasts for that page or attempt only; the next page is strict again.

Why this does not publish stale search results.

  • The index never gets anything the provider has not published: every document is read from the provider's pinned snapshot, exactly as a rebuild reads it. Nothing is invented from the receipt.
  • For a receipt that is ahead for good, the provider's current document is the newest that exists, so the index equals the source.
  • A strict fence is still used for the whole 30 s, which covers ordinary publication delay (milliseconds) and a long first scan (every batch publishes, so the page stages as soon as its note appears).
  • Known limit: if the provider publishes N only after 30 s of silence, the index shows the older text of that one note until it changes again or the Home reconciles at restart. I am not adding a deferred re-check in this PR; it will be a follow-up issue if wanted.

Tests. (1) A receipt ahead of any publication: sync_to_head finishes, the doc is the provider's current one, and fences_superseded() rose, within cap + slack, for both the catch-up path and the rebuild path. (2) A publication that arrives inside the cap is honoured: the indexed doc has the receipt's version and the counter did not rise. Plus the in-repo gap stage in the perf runner and its ssh retry.

Update (same day, after coding). Two details that were not in the note above:

  • After the first give-up in a pass, later pages in that pass wait only a tenth of the cap (3 s by default), because the Home is then known to hold receipts the provider never publishes.
  • The harness gap stage is --gap-saves N in crates/perf (with --search-only for the smoke set plus search). It makes a real gap through the real server: build the index (search.cold_reconcile), keep a copy, save N edits so every receipt is valid, then put the older index back. The earlier out-of-tree stage could not be recovered; this is a new, reproducible one.
## Rethink after the 2026-11-07 follow-up review The review found that the legacy-cursor path scanned pages to find the final page, then checked only that page. A pre-fence cursor can already cover a stale `notes.saved` entry several pages earlier, so this tail check cannot prove the whole cursor safe. The generation fence for new receipts remains unchanged; legacy cursor recovery is revised below. The implementation review found that ordinary room saves publish notes.saved through a separate path from Home executor actions. Both paths now attach the accepted per-note History version to the event and publish the same version with the accepted source. Room saves reuse the already durable Room.version; the version rides on the existing live_meta generation commit, with no added file read, wait, or fsync. The ordinary_room_save_receipt_matches_published_source_version regression proves that the receipt and provider agree. > ### Perf run note for 2026-11-08 > The perf VMs require a password for `sudo`, so the measurement user cannot run `calternal-perf --drop-caches`. The dev/dev and candidate/dev samples therefore use identical warm page-cache conditions. `cold.startup` measures a fresh unindexed Home with warm file pages; it does not qualify cold page-cache I/O. `search.catch_up` still compares the candidate's token catch-up with dev's full reconcile. ### Revised restart path - A current cursor with persisted page-start metadata is validated by `Engine::position`; the indexer re-reads its last journal page and checks each known source generation before trusting the cursor. - A cursor without page-start metadata is wholly untrusted. The indexer runs one full paged reconcile and scans retained save receipts from the oldest retained row through the captured head, so no earlier receipt is skipped. It uses the legacy token only as the use-score replay start, then publishes current documents, use scores, and the head token atomically. It does not upgrade legacy cursor metadata after checking only the tail. - The legacy reconcile is read-side only. It uses at most 256 journal entries, 256 provider rows, 64 document fetches, 512 compare metadata records, and a 2,000 KiB SQLite writer cache with fence state in a temporary file. Memory stays bounded by those page and batch caps; temporary disk is O(S) for changed rows and fences. - Normal current-cursor startup remains incremental: O(K log K + R + D) time and O(256 + R + 64) memory. The one-time legacy repair costs O(K + N log M + M) time, matching the existing full paged path, with bounded memory. Later starts use the normal incremental path. - If migration crashes before publish, the old cursor and index stay in place and the next start repeats the full reconcile. Notes saves do not change. | Failure | Effect | Detection | Recovery | Test | |---|---|---|---|---| | Legacy cursor has a raced receipt outside its final journal page | A tail-only check would leave stale text searchable | Missing page-start metadata triggers a receipt scan from the oldest retained row; unknown receipts are re-read from a pinned provider snapshot | Full paged reconcile; atomically publish documents and cursor after receipt and snapshot validation | `legacy_stale_receipt_before_final_page_forces_paged_reindex` | | Ordinary room-save receipt lacks source_version | The indexer cannot compare the receipt with the exact published Notes generation | The real-save test compares journal and provider versions | New room saves encode Room.version and publish it with live_meta; older versionless receipts stay on the unknown re-read path | ordinary_room_save_receipt_matches_published_source_version | | Crash during legacy reconcile | No mixed documents/cursor become visible | Reconcile has not committed | Retry the full paged reconcile on restart | Legacy stale-receipt recovery and page-boundary kill/restart tests | This one-time legacy path can take as long as today's full reconcile because its old checkpoint carries no proof of which earlier pages were verified. The performance table will separate this compatibility repair from current-cursor startup and report both against the same-epoch control. ## Design after the 2026-11-07 generation-fence ruling P1b stays a shared, backend-only search change. Notes remains the current provider; Mail can use the same cursor and page API later. Notes search, save behavior, result order, and UI stay unchanged. The indexer owns the fence: it will not index a source older than a `notes.saved` receipt or checkpoint past that receipt. ### Fence and restart rules `History::install_executor` already returns the accepted per-note version. Append that value as `source_version` to each new `notes.saved` event (at most 37 serialized bytes including its comma). Publish the same version with the accepted Notes source and expose it to search. Existing events without the field are `unknown`: read the item again from a fresh pinned Notes generation, compare its source stamp, and validate the snapshot before checkpointing. When a journal page touches an item, compare every saved version in that page with the published source version. If the source is behind, drop the private page stage, keep the previous cursor, and park the entry. Subscribe to the existing `MetaDb.populated` watch before pinning the provider snapshot; its publication notification retries the same page without a polling loop. If the watch produces no notification, allow five bounded exponential-backoff rereads (10, 20, 40, 80, 160 ms), then wait on the watch. A still-pending entry never advances the cursor. Every commit covers a contiguous run of verified entries, with documents, use scores, and the page token in one SQLite transaction. On startup, validate a current cursor and re-read the final journal page before trusting it. Store that page's starting token beside each new cursor. A legacy cursor without that metadata cannot identify which earlier receipts may have raced, so treat it as wholly untrusted and run a full paged provider reconcile. Publish the verified documents, use scores and current cursor together; a crash leaves the legacy cursor untrusted and the reconcile repeats. A missing or expired cursor does a full paged reconcile. Before publishing its head token, scan the retained journal through that head and stage the latest per-item fence in SQLite's temporary file. Compare each provider page against those fences; a pending source drops the whole private reconcile. A restored or truncated log is detected only through the engine contract: P1b uses `Engine::position` and `Engine::journal`; #928 remains the only owner of signed token proof and high-water restore detection. P1b does not read the high-water file or add/parse token formats. If #928 lands first, rebase and keep this API boundary. ### Sizes and cost | Work | Bound | Cost | |---|---:|---| | Incremental catch-up | 256 journal entries; 1,024 related IDs; 64 document payloads | `O(K log K + R + D)`; memory `O(256 + R + 64)` | | Cursor-tail recheck for a current cursor | 256 entries; one provider page | `O(256 + D)` time and memory | | One-time legacy cursor repair | Same page, fetch, SQLite cache and disk-fence caps as full reconcile | `O(K + N log M + M)` time, bounded memory | | Full reconcile | 256 provider rows; 64 document payloads; 512 compare metadata records; fence state in SQLite `temp_store=FILE`, 2,000 KiB writer cache | `O(K + N log M + M)` for `K` journal entries, `N` provider rows, `M` indexed rows; RAM independent of Home size; temp disk `O(S)` for changed rows and per-item fences | | Version metadata | ≤37 serialized bytes per event and accepted-source row | At most 37 MB raw for 1M fully versioned rows, before SQLite page overhead; no extra fsync or save-path read | No page uses `OFFSET` or retains a Home-sized vector. The version is returned by the existing history install; Notes does no extra work on the notes-save path beyond encoding the appended field. ### Failure table | Failure | Effect | Detection | Recovery | Test | |---|---|---|---|---| | `notes.saved` is visible before source publication | The old source cannot enter the index and the cursor stays before the receipt | Published source version is below the event version | Drop the page, wait on the existing publication watch, retry the same page | Real Notes executor delayed-publication race, incremental and missing-index cases | | Crash after receipt, before source publication | Receipt remains; cursor cannot pass it | Restart replays the durable executor record and rechecks the receipt version | Recovery publishes source; index resumes from the prior cursor | Crash/restart between journal receipt and publication | | Crash or kill at a page boundary | Private stage is discarded; committed documents and cursor agree | Reopen index and inspect the saved cursor | Replay the uncommitted page | `kill_restart_at_every_provider_page_boundary_converges` | | Legacy cursor lacks page-start metadata | A stale save may be older than the final journal page, so a tail-only check can miss it | Missing page-start metadata identifies the legacy cursor | Treat the cursor as untrusted and run a full paged reconcile before publishing any cursor | `legacy_stale_receipt_before_final_page_forces_paged_reindex` | | Cursor came from a restored older backup | Engine cannot prove it against the restored log | `Engine::position` returns `SyncTokenExpired` | Full paged reconcile; never construct a token locally | Restored-backup cursor test; #928 owns token-proof coverage | | Cursor is ahead or behind | Ahead/expired cursor cannot be used; retained behind cursor needs only its tail pages | `position` result plus page sequence checks | Full reconcile if expired; otherwise apply bounded pages | `ahead_cursor_reindexes_from_current_head`, `valid_behind_cursor_uses_pages_without_listing` | | Save log is truncated or index is missing | No trusted checkpoint remains | `position`/page read expires, or cursor is absent | Full paged reconcile with disk-backed fences and one atomic publish | `truncated_log_reindexes_from_pages`, `missing_index_rebuilds_in_pages` | | Publication notification is absent or the snapshot changes | No unverified page becomes visible | Bounded fallback retry; provider snapshot validation | Retry after a notification/backoff or discard and start a fresh reconcile | Watch and snapshot-change cases in the generation property test | ### Tests - Ordinary room save: edit and save a real Note, then prove the receipt version matches the published Notes source version. - Real Notes race: pause `EventRecorder::record_once` after the durable receipt and before it returns to `BatchPublished`; run incremental catch-up and missing-index reconcile; prove neither indexes the old text nor passes the cursor; release publication, restart the indexer, and prove the new text is indexed. - Crash before publication: stop after the receipt, reopen Notes so executor recovery replays it, and prove the cursor never skips the entry. - Reopen after every journal/provider page boundary and compare the final index to a clean build. A legacy cursor without page-start metadata must also repair a stale receipt more than 256 entries before the cursor. - Property test over save versions, delayed/reordered publication notifications, duplicate touches, arbitrary page cuts, and restarts; assert one indexed row per item, latest text, and a cursor no later than the contiguous verified prefix. - Restored-older-backup cursor, cursor ahead/behind, truncated log, missing index, and 1M-entry paged reconcile with a 256-row maximum and bounded memory. ### Gates | Gate | Exact command or run | Pass condition | |---|---|---| | Format | `CARGO_BUILD_JOBS=4 CARGO_INCREMENTAL=0 ~/bin/slot /nix/var/nix/profiles/default/bin/nix develop -c bash -c 'cd /home/claude/Developer/Worktrees/mail-p1b-test-e0fc && cargo fmt --check'` | Pass | | Clippy | `CARGO_BUILD_JOBS=4 CARGO_INCREMENTAL=0 ~/bin/slot /nix/var/nix/profiles/default/bin/nix develop -c bash -c 'cd /home/claude/Developer/Worktrees/mail-p1b-test-e0fc && cargo clippy --workspace --all-targets -- -D warnings'` | Pass | | Rust tests | `CARGO_BUILD_JOBS=4 CARGO_INCREMENTAL=0 ~/bin/slot /nix/var/nix/profiles/default/bin/nix develop -c bash -c 'cd /home/claude/Developer/Worktrees/mail-p1b-test-e0fc && cargo test --workspace --no-fail-fast'` | Pass | | Crash-typing flake | `cargo test -p calternal --test notes_crash_typing kill_nine_while_people_type_loses_and_doubles_nothing -- --exact` | 20 candidate and 20 dev runs interleaved; report both pass rates | | Chromium Notes search/save, 1440 and 390 | `~/bin/slot /nix/var/nix/profiles/default/bin/nix develop -c bash -c 'cd /home/claude/Developer/Worktrees/mail-p1b-test-e0fc/apps/web && CALTERNAL_BIN=/home/claude/Developer/Worktrees/mail-p1b-test-e0fc/target/debug/calternal bunx playwright test e2e/search-palette.spec.ts e2e/search-corpus.spec.ts e2e/editor.spec.ts e2e/list-catch-up.spec.ts --project=chromium-1440 --project=chromium-390 --workers=1'` | Pass | | WebKit Notes search/save, 1440 and 390 | `~/bin/slot /nix/var/nix/profiles/default/bin/nix develop -c bash -c 'cd /home/cua/Developer/Worktrees/mail-p1b-webkit-b822165c6/apps/web && CALTERNAL_BIN=/home/cua/Developer/Worktrees/mail-p1b-webkit-b822165c6/target/debug/calternal bunx playwright test e2e/search-palette.spec.ts e2e/search-corpus.spec.ts e2e/editor.spec.ts e2e/list-catch-up.spec.ts --project=webkit-1440 --project=webkit-390 --workers=1'` | Pass | | Perf | Hold `~/bin/perf-lock` on perf-01 then perf-02 for the complete same-epoch session. Run dev-vs-dev control and candidate/dev ABAB ×5; each sample runs `calternal-perf --bin "$SERVER_BIN" --work "$WORK" --data-dir "$DATA" --state-dir "$STATE" --budgets perf/budgets.json --sizes 100k,1000000 --runs 1 --cold-runs 1 --idle-secs 0 --json "$OUT/run.json" --md "$OUT/run.md"` and `storage-bench save --dir "$SAVE_DIR" --saves 200`. | Compare first query, query, catch-up, notes-save p50/p99, typing, and startup at 100k/1M beyond the dev-vs-dev spread. Every path is flat or better. The 1M reconcile must beat today's full path or the PR records the measured reason it does not. | Any regression beyond the control spread blocks qualification. Post commands, rates, all metric deltas, and the same-epoch control in PR comments. Never merge. ## Design note: the indexer never waits forever on a receipt fence (liveness fix, 2026-11-09) **Problem.** Search holds a save receipt back until the provider has published the version the receipt names (the "fence"). If that version is never published, `PublicationWait::retry` waits on the publication signal with no limit, and the full rebuild enforces the same fences, so it waits too. Search then reports `indexing: true` for ever. Seen on compute02 and perf-01 with the gap stage (idle server, `DIAG waiting for publication signal`). **"Receipt ahead of provider".** A receipt for item X names source version N (`SourceFence::Known(N)`), but the provider's published document for X has version M < N (or none), and no further publication arrives. Real ways to get there: a Home restored from an older backup, or note history rebuilt, while the save-log keeps its receipts. **The cap.** `Options::publication_cap`, default **30 s**, counted as time stuck on one page: it starts at the first reread for that page, restarts when the page is staged, and is not extended by publication signals for other items (so steady typing elsewhere cannot keep it alive). Tests set it to milliseconds. **After the cap (both places).** One relaxed attempt for that page or rebuild, using the same pinned provider snapshot: - journal path (`catch_up_to`, `recheck_cursor_tail`, `apply_live_batch`): the page is staged without its `Known` fences; - rebuild path (`reconcile_pages`): the attempt ignores `comparison.pending`, passes no fences to the refresh, and skips `has_unseen_known_fence`. The receipt is **superseded**: the provider's current document is indexed, the cursor advances, `indexing` goes false. One `WARN` per pass names the provider and the time waited, and the process-wide counter `calternal_search::fences_superseded()` goes up by one per relaxed page or rebuild. Relaxing lasts for that page or attempt only; the next page is strict again. **Why this does not publish stale search results.** - The index never gets anything the provider has not published: every document is read from the provider's pinned snapshot, exactly as a rebuild reads it. Nothing is invented from the receipt. - For a receipt that is ahead for good, the provider's current document is the newest that exists, so the index equals the source. - A strict fence is still used for the whole 30 s, which covers ordinary publication delay (milliseconds) and a long first scan (every batch publishes, so the page stages as soon as its note appears). - Known limit: if the provider publishes N only after 30 s of silence, the index shows the older text of that one note until it changes again or the Home reconciles at restart. I am not adding a deferred re-check in this PR; it will be a follow-up issue if wanted. **Tests.** (1) A receipt ahead of any publication: `sync_to_head` finishes, the doc is the provider's current one, and `fences_superseded()` rose, within cap + slack, for both the catch-up path and the rebuild path. (2) A publication that arrives inside the cap is honoured: the indexed doc has the receipt's version and the counter did not rise. Plus the in-repo gap stage in the perf runner and its ssh retry. **Update (same day, after coding).** Two details that were not in the note above: - After the first give-up in a pass, later pages in that pass wait only a tenth of the cap (3 s by default), because the Home is then known to hold receipts the provider never publishes. - The harness gap stage is `--gap-saves N` in `crates/perf` (with `--search-only` for the smoke set plus search). It makes a real gap through the real server: build the index (`search.cold_reconcile`), keep a copy, save N edits so every receipt is valid, then put the older index back. The earlier out-of-tree stage could not be recovered; this is a new, reproducible one.
kayg added 54 commits 2026-11-07 18:44:57 +00:00
chore(search): lock fixture filesystem dependency
Some checks failed
Markdown extraction contract / markdown-native-contract (pull_request) Has been cancelled
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-editor-contract (pull_request) Has been cancelled
000873f49e
Author
Owner

Crash-typing flake comparison

The first branch-native run reported candidate 18/20 and dev 2/20, but those runs used different test sources: the candidate test retries the documented retryable not_saved_yet response, while dev's older test expects an immediate 200. I reran the test interleaved with the exact candidate test source on both revisions (SHA-256 f9947402f29e4bacafbc5dc803c4236228411cd923bf63a80e2e65969b7d2555).

Revision Passes Failure
Candidate 0efea4a1 20/20 None
dev cd7f8443 19/20 One b never converged

Each arm ran the exact command CARGO_BUILD_JOBS=4 cargo test -p calternal --test notes_crash_typing kill_nine_while_people_type_loses_and_doubles_nothing -- --exact, alternating candidate then dev for 20 rounds. The dev-only failure is retained in the log; the candidate had no failures.

## Crash-typing flake comparison The first branch-native run reported candidate 18/20 and dev 2/20, but those runs used different test sources: the candidate test retries the documented retryable `not_saved_yet` response, while dev's older test expects an immediate 200. I reran the test interleaved with the exact candidate test source on both revisions (SHA-256 `f9947402f29e4bacafbc5dc803c4236228411cd923bf63a80e2e65969b7d2555`). | Revision | Passes | Failure | |---|---:|---| | Candidate `0efea4a1` | 20/20 | None | | dev `cd7f8443` | 19/20 | One `b never converged` | Each arm ran the exact command `CARGO_BUILD_JOBS=4 cargo test -p calternal --test notes_crash_typing kill_nine_while_people_type_loses_and_doubles_nothing -- --exact`, alternating candidate then dev for 20 rounds. The dev-only failure is retained in the log; the candidate had no failures.
Author
Owner

macOS gate rerun on 2026-11-08

#995 is closed and marked superseded by #1011. The open #1011 head 5a83ac274504b0b5fdb9e657cafa6a82e2a6544f has origin/dev merge-base 93d9a321a39044afddfe9075db2e1c1f729e3b78, so it already includes #1013.

The first Mac run exposed a test-fixture path collision: Notes::new colocates data and state, and case-insensitive APFS aliases <user>/Notes with <user>/notes. The write executor then correctly refused a journal inside Notes. Commits f73e93209 and 5a83ac274 change the P1b test fixtures to use separate data and state roots through Notes::with_state; Notes runtime behavior is unchanged.

Each Cargo gate below ran as its own Nix/slot step on /Users/lume/Developer/Worktrees/mail-p1b-mac-1011-eb1a4294, with a 40-minute per-step timeout. The helper acquired /tmp/mac-bench.lock, wrote its holder, and removed it in its EXIT trap before the next step. Other Mac lanes used the lock between our steps.

Gate Command inside the Nix dev shell Result
Format timeout --kill-after=30s 40m cargo fmt --check PASS
Clippy timeout --kill-after=30s 40m cargo clippy --workspace --all-targets -- -D warnings PASS
Search library timeout --kill-after=30s 40m cargo test -p calternal-search --lib PASS: 39 passed, 0 failed; includes the legacy cursor and delayed-publication cases
Workspace tests timeout --kill-after=30s 40m cargo test --workspace --no-fail-fast PASS: 1,608 passed, 0 failed, 22 ignored

The full suite's first Mac attempt also had one kill_nine_while_people_type_loses_and_doubles_nothing failure (b never converged). It passed on the final full-suite rerun. The requested interleaved dev-02 repetitions passed: candidate 20/20, dev 20/20, using cargo test -p calternal --test notes_crash_typing kill_nine_while_people_type_loses_and_doubles_nothing -- --exact.

P1b perf remains pending; these results make no performance claim.

## macOS gate rerun on 2026-11-08 #995 is closed and marked superseded by #1011. The open #1011 head `5a83ac274504b0b5fdb9e657cafa6a82e2a6544f` has `origin/dev` merge-base `93d9a321a39044afddfe9075db2e1c1f729e3b78`, so it already includes #1013. The first Mac run exposed a test-fixture path collision: `Notes::new` colocates data and state, and case-insensitive APFS aliases `<user>/Notes` with `<user>/notes`. The write executor then correctly refused a journal inside Notes. Commits `f73e93209` and `5a83ac274` change the P1b test fixtures to use separate data and state roots through `Notes::with_state`; Notes runtime behavior is unchanged. Each Cargo gate below ran as its own Nix/slot step on `/Users/lume/Developer/Worktrees/mail-p1b-mac-1011-eb1a4294`, with a 40-minute per-step timeout. The helper acquired `/tmp/mac-bench.lock`, wrote its holder, and removed it in its EXIT trap before the next step. Other Mac lanes used the lock between our steps. | Gate | Command inside the Nix dev shell | Result | |---|---|---| | Format | `timeout --kill-after=30s 40m cargo fmt --check` | PASS | | Clippy | `timeout --kill-after=30s 40m cargo clippy --workspace --all-targets -- -D warnings` | PASS | | Search library | `timeout --kill-after=30s 40m cargo test -p calternal-search --lib` | PASS: 39 passed, 0 failed; includes the legacy cursor and delayed-publication cases | | Workspace tests | `timeout --kill-after=30s 40m cargo test --workspace --no-fail-fast` | PASS: 1,608 passed, 0 failed, 22 ignored | The full suite's first Mac attempt also had one `kill_nine_while_people_type_loses_and_doubles_nothing` failure (`b never converged`). It passed on the final full-suite rerun. The requested interleaved dev-02 repetitions passed: candidate 20/20, dev 20/20, using `cargo test -p calternal --test notes_crash_typing kill_nine_while_people_type_loses_and_doubles_nothing -- --exact`. P1b perf remains pending; these results make no performance claim.
Author
Owner

P1b perf ABAB status, 2026-11-09 ~10:45 CET (no numbers yet)

Head under test: 02baeb54212095d956d1fcce49594d6c36d36ea2. Staged binaries verified with sha256sum -c.

Time (CET) Event
05:51-06:14 First matrix: stopped itself at the 15 GB disk floor (exit 70). I freed my predecessor's data/state dirs (exact paths).
06:17-06:49 Second matrix: dev control and block-1-a1-dev finished. block-1-a2-candidate then stalled at "100000 notes, warm run 1" from 06:49. Harness and server were both idle, no sockets, every thread in futex/epoll wait. I stopped my own unit. Cause not found: the same stage passed on both dev arms.
08:55-09:11 Third matrix: the 1M-note cold run fails with notes.list 500 on dev too, at the same step as before. The 100k cold index writes 4.5 GB, so 1M needs about 45 GB, and the shared perf disk has 16-25 GB free. Unconfirmed as ENOSPC.

Changes to the rig: 100k only (no 1M), 25-minute per-arm timeout with one retry.

Not done: the ABAB x5 and the dev-vs-dev control. Another lane held perf-01 for over 3 hours after 09:11, and I did not get a turn. I cancelled my queued unit and hold no lock.

The candidate stall is unresolved. If it recurs under the new timeout, treat it as a PR bug: capture its stack and fix it before merge.

## P1b perf ABAB status, 2026-11-09 ~10:45 CET (no numbers yet) Head under test: `02baeb54212095d956d1fcce49594d6c36d36ea2`. Staged binaries verified with `sha256sum -c`. | Time (CET) | Event | |---|---| | 05:51-06:14 | First matrix: stopped itself at the 15 GB disk floor (exit 70). I freed my predecessor's `data`/`state` dirs (exact paths). | | 06:17-06:49 | Second matrix: dev control and `block-1-a1-dev` finished. `block-1-a2-candidate` then stalled at "100000 notes, warm run 1" from 06:49. Harness and server were both idle, no sockets, every thread in futex/epoll wait. I stopped my own unit. Cause not found: the same stage passed on both dev arms. | | 08:55-09:11 | Third matrix: the 1M-note cold run fails with `notes.list` 500 on **dev** too, at the same step as before. The 100k cold index writes 4.5 GB, so 1M needs about 45 GB, and the shared perf disk has 16-25 GB free. Unconfirmed as ENOSPC. | Changes to the rig: 100k only (no 1M), 25-minute per-arm timeout with one retry. Not done: the ABAB x5 and the dev-vs-dev control. Another lane held perf-01 for over 3 hours after 09:11, and I did not get a turn. I cancelled my queued unit and hold no lock. The candidate stall is unresolved. If it recurs under the new timeout, treat it as a PR bug: capture its stack and fix it before merge.
Author
Owner

P1b perf turn 2, 2026-11-09 (FIFO): candidate warm-run stall reproduced, no ABAB numbers

PR head (API head.sha): 02baeb54212095d956d1fcce49594d6c36d36ea2. refs/pull/1011/head still shows 000873f49…, which is the stale-ref gotcha; the branch t3/paged-search-reconcile-final is at 02baeb542.

Item Result
Turn Held perf-01 and perf-02 from 11:32 CET (FIFO). 100k only; 1M dropped (see #1028).
block-1-a1-dev Finished: 6 min.
block-1-a2-candidate Stalled again at 100000 notes, warm run 1 from 11:39:35 CET, same as the 06:49 stall in the first session.
Stall state Server healthy: GET /healthz returned 200 on its real port. Server idle: search-writer parked on an empty std::sync::mpmc::Channel<calternal_search::index::Job>, all tokio workers in futex wait. Harness: main thread parked in tokio::runtime::park::Inner::park under calternal_perf::main, all workers parked, one worker in epoll_wait, no TCP connection open, no timer armed.
Stacks gdb -p <pid> thread apply all bt of both processes, kept on perf-01 under results-turn-patched-harness/block-1-a2-candidate/stall-gdb-*.txt.
Stopped I stopped my own unit; both locks released at 11:46 CET.

Reading: the harness is waiting on something that never arrives, while the server has finished its work. Dev arms pass the same stage on the same harness build. The staged harness (harness/*/calternal-perf, sha 21c0679b… candidate, e02f9fc2… dev) contains an "offline saves for a warm search catch-up gap" edit that is not in 02baeb542, and its source is in no worktree I can find. So I cannot yet say whether the stall is in the candidate server or in that edit.

Next test, queued but not run: the clean harnesses built from each tree (bin/*/calternal-perf, c6149a26… candidate, fa53d86f… dev). If the stall disappears, it is the edit. If it stays, it is a PR bug and needs a fix on compute02 before merge.

Not run: the ABAB x5 and any per-metric verdict.

Process notes: ~/bin/perf-turn was edited while my waiting copy ran, so bash hit syntax error near unexpected token done at 13:56 CET and my ticket (2 h into the wait) was dropped. A ticket named 0000000000-782670-sharing-842b (timestamp 0) was at the head of the line for about an hour. I now hold no ticket and no lock.

## P1b perf turn 2, 2026-11-09 (FIFO): candidate warm-run stall reproduced, no ABAB numbers PR head (API `head.sha`): `02baeb54212095d956d1fcce49594d6c36d36ea2`. `refs/pull/1011/head` still shows `000873f49…`, which is the stale-ref gotcha; the branch `t3/paged-search-reconcile-final` is at `02baeb542`. | Item | Result | |---|---| | Turn | Held perf-01 and perf-02 from 11:32 CET (FIFO). 100k only; 1M dropped (see #1028). | | `block-1-a1-dev` | Finished: 6 min. | | `block-1-a2-candidate` | **Stalled again** at `100000 notes, warm run 1` from 11:39:35 CET, same as the 06:49 stall in the first session. | | Stall state | Server healthy: `GET /healthz` returned 200 on its real port. Server idle: `search-writer` parked on an empty `std::sync::mpmc::Channel<calternal_search::index::Job>`, all tokio workers in futex wait. Harness: main thread parked in `tokio::runtime::park::Inner::park` under `calternal_perf::main`, all workers parked, one worker in `epoll_wait`, no TCP connection open, no timer armed. | | Stacks | `gdb -p <pid> thread apply all bt` of both processes, kept on perf-01 under `results-turn-patched-harness/block-1-a2-candidate/stall-gdb-*.txt`. | | Stopped | I stopped my own unit; both locks released at 11:46 CET. | Reading: the harness is waiting on something that never arrives, while the server has finished its work. Dev arms pass the same stage on the same harness build. The staged harness (`harness/*/calternal-perf`, sha `21c0679b…` candidate, `e02f9fc2…` dev) contains an "offline saves for a warm search catch-up gap" edit that is not in `02baeb542`, and its source is in no worktree I can find. So I cannot yet say whether the stall is in the candidate server or in that edit. Next test, queued but not run: the clean harnesses built from each tree (`bin/*/calternal-perf`, `c6149a26…` candidate, `fa53d86f…` dev). If the stall disappears, it is the edit. If it stays, it is a PR bug and needs a fix on compute02 before merge. Not run: the ABAB x5 and any per-metric verdict. Process notes: `~/bin/perf-turn` was edited while my waiting copy ran, so bash hit `syntax error near unexpected token done` at 13:56 CET and my ticket (2 h into the wait) was dropped. A ticket named `0000000000-782670-sharing-842b` (timestamp 0) was at the head of the line for about an hour. I now hold no ticket and no lock.
Author
Owner

P1b: stall root-caused off-lock (compute02, no perf lock), Mac gates re-run at 02baeb542

PR head (API): 02baeb54212095d956d1fcce49594d6c36d36ea2. No perf numbers yet; I did not take the perf turn because the stall is a design question (below).

Mac gates at 02baeb542 (macos-01, one lock hold per step, each released)

Gate Command (inside the Nix dev shell) Result
Format cargo fmt --check PASS
Clippy cargo clippy --workspace --all-targets -- -D warnings PASS
Search lib cargo test -p calternal-search --lib PASS: 40 passed, 0 failed
Workspace cargo test --workspace --no-fail-fast PASS: 1,609 passed, 0 failed, 22 ignored

Stall repro, compute02 (12 cores), 100k warm, 20 min cap, no perf lock

Harness Server Result
clean (built from each tree) dev pass, rc=0
clean candidate pass, rc=0 (6 min)
edited dev harness (e02f9fc2…, has the save-log gap stage) dev pass, rc=0
edited candidate harness (21c0679b…, gap stage) candidate stalls at "warm run 1", rc=124, 2 of 2 runs
edited candidate harness dev slow, not stuck: notes.list incomplete: true, host load ~35 (rc=124 at the cap)

The clean harness has no gap stage, so search.catch_up is about 0 s and search.cold_reconcile is absent. It does not measure what #1011 changes. The edited harnesses' gap source is in no repo or worktree I could find.

Root cause (candidate server)

At the stall the server answers /healthz 200 and notes.list returns incomplete: false, but search.query returns indexing: true indefinitely, with every thread idle. A diagnostic build (extra warn! only) logged DIAG waiting for publication signal provider="notes" and never logged that it arrived. The indexer is parked in PublicationWait::retry (crates/search/src/indexer/sync.rs): after its 5 backoff rereads it waits on receiver.changed().await with no cap, for a receipt whose source_version is ahead of what the notes provider publishes. Nothing publishes again, because the notes scan is already finished.

What I tried and why I stopped

I capped that wait at 30 s and returned SyncTokenExpired so the caller rebuilds. The stall changed shape but did not go away: the rebuild (reconcile_pages) enforces the same receipt fences, so it waits and times out too, and the log repeats search receipt was never published; rebuilding / search could not synchronize its index. Diff kept on compute02 at ~/perf/mail-1011-repro/bounded-wait-experiment.diff, not pushed.

So the fence design has no escape when a receipt's version is never published. Decision needed from the owner, not a quick patch:

  1. If the gap stage's receipts are not valid (version ahead of anything the notes history can reach), fix the harness gap data and keep the fence as designed. Its source is needed for that.
  2. If a real Home can reach that state (history rebuilt, restored from an older backup), the fence needs a defined exit, e.g. after a cap the rebuild accepts the provider's current state, drops that receipt's fence and logs it, with a test.

Cleanup: no ticket, no lock, no unit left on perf-01, perf-02 or compute02. Repro files kept at ~/perf/mail-1011-repro on compute02 (data 1.5 GB).

## P1b: stall root-caused off-lock (compute02, no perf lock), Mac gates re-run at `02baeb542` PR head (API): `02baeb54212095d956d1fcce49594d6c36d36ea2`. No perf numbers yet; I did not take the perf turn because the stall is a design question (below). ### Mac gates at `02baeb542` (macos-01, one lock hold per step, each released) | Gate | Command (inside the Nix dev shell) | Result | |---|---|---| | Format | `cargo fmt --check` | PASS | | Clippy | `cargo clippy --workspace --all-targets -- -D warnings` | PASS | | Search lib | `cargo test -p calternal-search --lib` | PASS: 40 passed, 0 failed | | Workspace | `cargo test --workspace --no-fail-fast` | PASS: 1,609 passed, 0 failed, 22 ignored | ### Stall repro, compute02 (12 cores), 100k warm, 20 min cap, no perf lock | Harness | Server | Result | |---|---|---| | clean (built from each tree) | dev | pass, rc=0 | | clean | candidate | pass, rc=0 (6 min) | | edited dev harness (`e02f9fc2…`, has the save-log gap stage) | dev | pass, rc=0 | | edited candidate harness (`21c0679b…`, gap stage) | candidate | **stalls at "warm run 1", rc=124, 2 of 2 runs** | | edited candidate harness | dev | slow, not stuck: `notes.list incomplete: true`, host load ~35 (rc=124 at the cap) | The clean harness has no gap stage, so `search.catch_up` is about 0 s and `search.cold_reconcile` is absent. It does not measure what #1011 changes. The edited harnesses' gap source is in no repo or worktree I could find. ### Root cause (candidate server) At the stall the server answers `/healthz` 200 and `notes.list` returns `incomplete: false`, but `search.query` returns `indexing: true` indefinitely, with every thread idle. A diagnostic build (extra `warn!` only) logged `DIAG waiting for publication signal provider="notes"` and never logged that it arrived. The indexer is parked in `PublicationWait::retry` (`crates/search/src/indexer/sync.rs`): after its 5 backoff rereads it waits on `receiver.changed().await` with no cap, for a receipt whose `source_version` is ahead of what the notes provider publishes. Nothing publishes again, because the notes scan is already finished. ### What I tried and why I stopped I capped that wait at 30 s and returned `SyncTokenExpired` so the caller rebuilds. The stall changed shape but did not go away: the rebuild (`reconcile_pages`) enforces the same receipt fences, so it waits and times out too, and the log repeats `search receipt was never published; rebuilding` / `search could not synchronize its index`. Diff kept on compute02 at `~/perf/mail-1011-repro/bounded-wait-experiment.diff`, not pushed. So the fence design has no escape when a receipt's version is never published. Decision needed from the owner, not a quick patch: 1. If the gap stage's receipts are not valid (version ahead of anything the notes history can reach), fix the harness gap data and keep the fence as designed. Its source is needed for that. 2. If a real Home can reach that state (history rebuilt, restored from an older backup), the fence needs a defined exit, e.g. after a cap the rebuild accepts the provider's current state, drops that receipt's fence and logs it, with a test. Cleanup: no ticket, no lock, no unit left on perf-01, perf-02 or compute02. Repro files kept at `~/perf/mail-1011-repro` on compute02 (data 1.5 GB).
Author
Owner

P1b perf ABAB x5 with the save-log gap stage, 100k, perf-01/perf-02 (2026-11-09 18:52-19:30 CET)

PR head dcb50cda8df62e2cad6d3fdd9218f7b3538f6352 (candidate server built from it; harness --gap-saves 600 --search-only). Dev = 93d9a321 build. Run through plain FIFO perf-turn (front-of-line grant), both perf locks held for the whole run, released after.

Order per block: dev, candidate, dev, candidate; 5 blocks, 20 arms, every arm passed (no stall, no failure). The control is dev vs dev: "spread" is the median relative gap between the two dev arms of a block.

arms: 20 failures: []
| metric | stat | dev median | cand median | delta | dev-vs-dev spread (median |a1-a3|) | cand/dev blocks worse | verdict |
|---|---|---:|---:|---:|---:|---:|---|
| search.catch_up | p50 | 2.01 | 2.01 | -0.3% | 0.4% | 1/5 | better |
| search.cold_reconcile | p50 | 47.9 | 49.2 | +2.8% | 2.3% | 4/5 | SLOWER beyond noise |
| search.query | p50 | 1.61 | 3.2 | +98.1% | 8.1% | 5/5 | SLOWER beyond noise |
| search.query | p95 | 3.94 | 7.46 | +89.6% | 8.2% | 5/5 | SLOWER beyond noise |
| search.first_query | p50 | 3.44e+03 | 2.09e+03 | -39.1% | 18.7% | 0/5 | better |
| startup.healthz | p50 | 5.15 | 5.28 | +2.5% | 31.3% | 2/5 | flat/better |
| open.api_get | p50 | 2.49 | 2.94 | +18.1% | 6.4% | 4/5 | SLOWER beyond noise |
| open.api_get | p95 | 21.9 | 20.5 | -6.5% | 10.9% | 1/5 | better |
| open.note | p50 | 2.53 | 3.27 | +29.2% | 6.1% | 5/5 | SLOWER beyond noise |
| open.note | p95 | 9.61 | 98.7 | +927.0% | 23.6% | 5/5 | SLOWER beyond noise |

This is not mergeable as it stands. search.query is consistently about 2x slower on the candidate in all 5 blocks (dev 1.5-1.7 ms, candidate 3.0-3.7 ms at p50; p95 3.9 vs 7.4 ms), far outside the dev-vs-dev spread. open.note p50 is a little higher (about +0.5 ms) and its p95 is outlier-driven (one ~100 ms open in 7 of 10 candidate arms against 1 of 10 dev arms). search.cold_reconcile is +2.8% against a 2.3% spread (borderline). search.first_query is better and search.catch_up is flat.

Caveats on this table:

  • search.catch_up reads 2.01 s in both arms because the harness polled "still indexing?" every 2 s, so any catch-up under 2 s is invisible. The poll is now 50 ms in ae2383a7d (harness only); a second turn with the fine harness is needed for a real catch-up number.
  • 1M notes is not measured (#1028).

Investigating the search.query slowdown next (index shape after the paged rebuild is the first suspect; no read-path code changed in the PR).

## P1b perf ABAB x5 with the save-log gap stage, 100k, perf-01/perf-02 (2026-11-09 18:52-19:30 CET) PR head `dcb50cda8df62e2cad6d3fdd9218f7b3538f6352` (candidate server built from it; harness `--gap-saves 600 --search-only`). Dev = `93d9a321` build. Run through plain FIFO `perf-turn` (front-of-line grant), both perf locks held for the whole run, released after. Order per block: dev, candidate, dev, candidate; 5 blocks, 20 arms, every arm passed (no stall, no failure). The control is dev vs dev: "spread" is the median relative gap between the two dev arms of a block. arms: 20 failures: [] | metric | stat | dev median | cand median | delta | dev-vs-dev spread (median |a1-a3|) | cand/dev blocks worse | verdict | |---|---|---:|---:|---:|---:|---:|---| | search.catch_up | p50 | 2.01 | 2.01 | -0.3% | 0.4% | 1/5 | better | | search.cold_reconcile | p50 | 47.9 | 49.2 | +2.8% | 2.3% | 4/5 | SLOWER beyond noise | | search.query | p50 | 1.61 | 3.2 | +98.1% | 8.1% | 5/5 | SLOWER beyond noise | | search.query | p95 | 3.94 | 7.46 | +89.6% | 8.2% | 5/5 | SLOWER beyond noise | | search.first_query | p50 | 3.44e+03 | 2.09e+03 | -39.1% | 18.7% | 0/5 | better | | startup.healthz | p50 | 5.15 | 5.28 | +2.5% | 31.3% | 2/5 | flat/better | | open.api_get | p50 | 2.49 | 2.94 | +18.1% | 6.4% | 4/5 | SLOWER beyond noise | | open.api_get | p95 | 21.9 | 20.5 | -6.5% | 10.9% | 1/5 | better | | open.note | p50 | 2.53 | 3.27 | +29.2% | 6.1% | 5/5 | SLOWER beyond noise | | open.note | p95 | 9.61 | 98.7 | +927.0% | 23.6% | 5/5 | SLOWER beyond noise | **This is not mergeable as it stands.** `search.query` is consistently about 2x slower on the candidate in all 5 blocks (dev 1.5-1.7 ms, candidate 3.0-3.7 ms at p50; p95 3.9 vs 7.4 ms), far outside the dev-vs-dev spread. `open.note` p50 is a little higher (about +0.5 ms) and its p95 is outlier-driven (one ~100 ms open in 7 of 10 candidate arms against 1 of 10 dev arms). `search.cold_reconcile` is +2.8% against a 2.3% spread (borderline). `search.first_query` is better and `search.catch_up` is flat. Caveats on this table: - `search.catch_up` reads 2.01 s in both arms because the harness polled "still indexing?" every 2 s, so any catch-up under 2 s is invisible. The poll is now 50 ms in `ae2383a7d` (harness only); a second turn with the fine harness is needed for a real catch-up number. - 1M notes is not measured (#1028). Investigating the `search.query` slowdown next (index shape after the paged rebuild is the first suspect; no read-path code changed in the PR).
Author
Owner

P1b: liveness fix done; perf regression on search.query found, plan below (stopping, not patching)

PR head dcb50cda8df62e2cad6d3fdd9218f7b3538f6352 (the liveness fix and the gap stage are pushed to it; ae2383a7d on the side branch t3/mail-1011-liveness adds a 50 ms catch-up poll to the harness and is not on the PR yet).

Done

  • Stall fixed in both places (crates/search/src/indexer/publication.rs, sync.rs): the wait is capped (Options::publication_cap, 30 s) and the page or rebuild is then staged without its fences. Counter fences_superseded(), one warn per pass.
  • Tests: 4 new in fence_liveness.rs (receipt ahead of provider finishes on the catch-up path and on the rebuild path; late publication inside the cap is honoured on both). Search lib: 44 passed.
  • Gap stage in the repo: --gap-saves N, --search-only. Candidate with gap stage: 3/3 warm runs pass on compute02 (the stall was 2/2 before).
  • Mac gates at dcb50cda8 (macos-01): fmt, clippy pass; search lib 44 passed; workspace 1,614 passed, 0 failed, 22 ignored. The first Mac run at b4cb96a7e had one kill_nine_while_people_type_loses_and_doubles_nothing failure; ten reruns at dcb50cda8 gave 8 pass, 2 FAIL (13.6 s, the same failure shape). It is the known flaky test (see the 11-08 comment: dev also failed 1 of 20 on Linux), but I have not shown it is unrelated on macOS, so I am not calling it clean.
  • ABAB x5 with gap stage: table in the comment above. All 20 arms passed.

Not mergeable: search.query about 2x slower (5 of 5 blocks)

p50 dev 1.5-1.7 ms vs candidate 3.0-3.7 ms; p95 3.9 vs 7.4 ms. Also open.note p50 +0.5 ms (p95 outliers of ~100 ms in 7 of 10 candidate arms), search.cold_reconcile +2.8% (spread 2.3%). Better: search.first_query (-39%); flat: search.catch_up (but the poll was too coarse to see it).

What I narrowed down (compute02, loaded, so ratios only)

  • The query path is unchanged in the PR (Search::query and index.search are the same code).
  • Final index shape is identical between arms (100,000 docs, same FTS/title/trigram row counts, same page count). Only the WAL differs (81 MB candidate, 61 MB dev).
  • Without the gap stage the candidate is not slower (search.query p50 5.1 / 3.6 ms vs dev 7.5 / 8.2 ms). So the slowdown comes from the save-log catch-up path leaving the index in a state that queries more slowly, not from the cold build or the query code.

Plan (needs a decision: this is round 2 of "new problem found", so no blind patch)

  1. Reproduce on perf-01 with the fine harness (ae2383a7d), gap on, and read PRAGMA wal_checkpoint and WAL size at query time for both arms (one front-of-line turn, 30 min).
  2. If the WAL is the cause (candidate publishes each catch-up page as its own WAL commit, and wal_autocheckpoint = 0): checkpoint (passive) once after catch-up finishes, in the indexer, with a test that WAL size is bounded after a catch-up of N pages.
  3. If not the WAL: compare fts segment structure and ANALYZE/stat tables between arms, then the generation/vocab cache invalidation counts (candidate bumps generation once per page).
  4. Re-run the ABAB with search.query as the gate. Nothing merges until search.query, open.note and cold_reconcile are flat against dev.

Cleanup done: compute02 repro data and targets deleted (59 MB of scripts left), perf-01 run data deleted, no ticket, lock or unit held on either perf VM.

## P1b: liveness fix done; perf regression on `search.query` found, plan below (stopping, not patching) PR head `dcb50cda8df62e2cad6d3fdd9218f7b3538f6352` (the liveness fix and the gap stage are pushed to it; `ae2383a7d` on the side branch `t3/mail-1011-liveness` adds a 50 ms catch-up poll to the harness and is not on the PR yet). ### Done - **Stall fixed in both places** (`crates/search/src/indexer/publication.rs`, `sync.rs`): the wait is capped (`Options::publication_cap`, 30 s) and the page or rebuild is then staged without its fences. Counter `fences_superseded()`, one warn per pass. - **Tests:** 4 new in `fence_liveness.rs` (receipt ahead of provider finishes on the catch-up path and on the rebuild path; late publication inside the cap is honoured on both). Search lib: 44 passed. - **Gap stage in the repo:** `--gap-saves N`, `--search-only`. Candidate with gap stage: 3/3 warm runs pass on compute02 (the stall was 2/2 before). - **Mac gates at `dcb50cda8`** (macos-01): fmt, clippy pass; search lib 44 passed; workspace 1,614 passed, 0 failed, 22 ignored. The first Mac run at `b4cb96a7e` had one `kill_nine_while_people_type_loses_and_doubles_nothing` failure; ten reruns at `dcb50cda8` gave 8 pass, 2 FAIL (13.6 s, the same failure shape). It is the known flaky test (see the 11-08 comment: dev also failed 1 of 20 on Linux), but I have not shown it is unrelated on macOS, so I am not calling it clean. - **ABAB x5 with gap stage**: table in the comment above. All 20 arms passed. ### Not mergeable: `search.query` about 2x slower (5 of 5 blocks) p50 dev 1.5-1.7 ms vs candidate 3.0-3.7 ms; p95 3.9 vs 7.4 ms. Also `open.note` p50 +0.5 ms (p95 outliers of ~100 ms in 7 of 10 candidate arms), `search.cold_reconcile` +2.8% (spread 2.3%). Better: `search.first_query` (-39%); flat: `search.catch_up` (but the poll was too coarse to see it). ### What I narrowed down (compute02, loaded, so ratios only) - The query path is unchanged in the PR (`Search::query` and `index.search` are the same code). - Final index shape is identical between arms (100,000 docs, same FTS/title/trigram row counts, same page count). Only the WAL differs (81 MB candidate, 61 MB dev). - **Without the gap stage the candidate is not slower** (`search.query` p50 5.1 / 3.6 ms vs dev 7.5 / 8.2 ms). So the slowdown comes from the save-log catch-up path leaving the index in a state that queries more slowly, not from the cold build or the query code. ### Plan (needs a decision: this is round 2 of "new problem found", so no blind patch) 1. Reproduce on perf-01 with the fine harness (`ae2383a7d`), gap on, and read `PRAGMA wal_checkpoint` and WAL size at query time for both arms (one front-of-line turn, 30 min). 2. If the WAL is the cause (candidate publishes each catch-up page as its own WAL commit, and `wal_autocheckpoint = 0`): checkpoint (passive) once after catch-up finishes, in the indexer, with a test that WAL size is bounded after a catch-up of N pages. 3. If not the WAL: compare `fts` segment structure and `ANALYZE`/stat tables between arms, then the `generation`/vocab cache invalidation counts (candidate bumps `generation` once per page). 4. Re-run the ABAB with `search.query` as the gate. Nothing merges until `search.query`, `open.note` and `cold_reconcile` are flat against dev. Cleanup done: compute02 repro data and targets deleted (59 MB of scripts left), perf-01 run data deleted, no ticket, lock or unit held on either perf VM.
Author
Owner

P1b round 2: search.query regression explained (harness artifact); ABAB x5 re-run; two gates still open

PR head 3d5999c7a775725b842ae85fbec24d08f139d78f (candidate server = the PR's search code; the commits since dcb50cda8 are harness-only: 50 ms catch-up poll, populated-baseline gap stage).

Why search.query looked 2x slower

  • Cross-test on compute02: the index state decides it, not the server binary. A state built by the candidate's catch-up answers in ~7 ms under either binary; the dev-built state in ~3.4 ms under either.
  • Table pages, fill, row counts and FTS segments are identical. The one difference: the dev-built state has 0 frecency rows, the candidate-built one 593. The candidate's catch-up replays the save "uses" (correct); dev's legacy-cursor path deliberately skips them.
  • read.rs::frecent() returns at once when frecency is empty; otherwise it reads the 64 most recent used notes for every query. A fixed cost that saturates at 64 rows, which every Home in use pays on dev too.
  • Proof by swap: with 593 rows inserted into the dev state and the candidate state emptied, the slow/fast pattern inverted under both binaries.
  • WAL is not involved (the writer already checkpoints passively after 250 ms of quiet); no checkpoint change is needed, so I did not add one.
  • Fix is in the harness only (3d5999c7a): the gap stage opens 100 notes before the gap so both arms start with a used-notes table (checked: dev arm 100 rows, candidate 593).

ABAB x5, 100k, gap stage, populated baseline (perf-01/02, 2026-11-10 06:36-~07:30 CET), 20 arms, 0 failures

arms: 20 failures: []
| metric | stat | dev median | cand median | delta | dev-vs-dev spread (median |a1-a3|) | cand/dev blocks worse | verdict |
|---|---|---:|---:|---:|---:|---:|---|
| search.catch_up | p50 | 1.27 | 0.85 | -33.0% | 3.0% | 0/5 | better |
| search.cold_reconcile | p50 | 45.6 | 47.3 | +3.5% | 1.2% | 5/5 | SLOWER beyond noise |
| search.query | p50 | 3.34 | 3.23 | -3.4% | 7.3% | 2/5 | better |
| search.query | p95 | 7.39 | 7.48 | +1.2% | 8.4% | 3/5 | flat/better |
| search.first_query | p50 | 5.62 | 7.43 | +32.2% | 11.0% | 5/5 | SLOWER beyond noise |
| startup.healthz | p50 | 5.55 | 5.05 | -9.1% | 47.2% | 0/5 | better |
| open.api_get | p50 | 0.851 | 0.819 | -3.8% | 6.8% | 3/5 | better |
| open.api_get | p95 | 3.89 | 4.61 | +18.5% | 238.4% | 4/5 | flat/better |
| open.note | p50 | 0.947 | 0.851 | -10.1% | 16.3% | 2/5 | better |
| open.note | p95 | 36.7 | 4.86 | -86.8% | 16.1% | 0/5 | better |

Gate "search.query, open.note, cold_reconcile all <= dev"

  • search.query p50 3.34 -> 3.23 ms, p95 7.39 -> 7.48 ms: flat (inside the 7-8% spread). Pass.
  • open.note p50 -10%, p95 36.7 -> 4.9 ms: pass (dev p95 had a ~90 ms outlier in 3 of 10 arms).
  • search.catch_up 1.27 -> 0.85 s (-33%, 0/5 blocks worse): better.
  • search.cold_reconcile 45.6 -> 47.3 s (+3.5%, 5 of 5 blocks worse, spread 1.2%): FAIL, a steady ~+2 s. Likely the receipt-fence scan the rebuild now does before listing providers (stage_source_fences, then fence joins in compare_page); not yet profiled.
  • search.first_query p50 5.6 -> 7.4 ms (+32%, 5 of 5 blocks): mostly 4 of 10 candidate arms at 9.9-17.7 ms; the other arms are 5-7 ms like dev. Small in absolute terms but not flat: FAIL by the no-regression rule until explained.

macOS flake kill_nine_while_people_type_loses_and_doubles_nothing (macos-01, same command, 20 runs each)

  • dev 9438918f3: 20/20 pass.
  • PR head: 2/20 fail (13.6 s, ... never converged, the rejoined-tab text check at notes_crash_typing.rs:413). Earlier PR runs: 1 of 1 and 2 of 10 failed. Pooled that is 5 failures in ~31 PR runs vs 0 in 20 on dev.
  • So I can no longer call it pre-existing on macOS. The PR changes the Notes room/publish path (room/save.rs, room/mod.rs listed now keyed by version, meta.rs live_meta gets source_version). Not diagnosed.

State

Liveness fix, tests and gap stage are pushed. Not mergeable: cold_reconcile and first_query regress, and the Mac flake looks PR-specific. Two follow-ups for a decision (the 3-round rule applies, so I am stopping here):

  1. Profile the rebuild's fence scan on perf (cold_reconcile +2 s), then either speed it up or accept it as the cost of fenced receipts, with kayg's call since the rule is "no regression".
  2. Bisect the Mac flake over the Notes-side commits (20 runs per step on macos-01).
    Also worth its own issue: search.query pays a fixed frecent() cost for any Home with 64+ used notes, on dev too.

Cleanup: perf-01/perf-02 locks and units released, compute02 and perf-01 run data removed.

## P1b round 2: `search.query` regression explained (harness artifact); ABAB x5 re-run; two gates still open PR head `3d5999c7a775725b842ae85fbec24d08f139d78f` (candidate server = the PR's search code; the commits since `dcb50cda8` are harness-only: 50 ms catch-up poll, populated-baseline gap stage). ### Why `search.query` looked 2x slower - Cross-test on compute02: the **index state** decides it, not the server binary. A state built by the candidate's catch-up answers in ~7 ms under either binary; the dev-built state in ~3.4 ms under either. - Table pages, fill, row counts and FTS segments are identical. The one difference: the dev-built state has **0 `frecency` rows**, the candidate-built one 593. The candidate's catch-up replays the save "uses" (correct); dev's legacy-cursor path deliberately skips them. - `read.rs::frecent()` returns at once when `frecency` is empty; otherwise it reads the 64 most recent used notes for every query. A fixed cost that saturates at 64 rows, which every Home in use pays on dev too. - Proof by swap: with 593 rows inserted into the dev state and the candidate state emptied, the slow/fast pattern inverted under both binaries. - WAL is not involved (the writer already checkpoints passively after 250 ms of quiet); no checkpoint change is needed, so I did not add one. - Fix is in the harness only (`3d5999c7a`): the gap stage opens 100 notes before the gap so both arms start with a used-notes table (checked: dev arm 100 rows, candidate 593). ### ABAB x5, 100k, gap stage, populated baseline (perf-01/02, 2026-11-10 06:36-~07:30 CET), 20 arms, 0 failures arms: 20 failures: [] | metric | stat | dev median | cand median | delta | dev-vs-dev spread (median |a1-a3|) | cand/dev blocks worse | verdict | |---|---|---:|---:|---:|---:|---:|---| | search.catch_up | p50 | 1.27 | 0.85 | -33.0% | 3.0% | 0/5 | better | | search.cold_reconcile | p50 | 45.6 | 47.3 | +3.5% | 1.2% | 5/5 | SLOWER beyond noise | | search.query | p50 | 3.34 | 3.23 | -3.4% | 7.3% | 2/5 | better | | search.query | p95 | 7.39 | 7.48 | +1.2% | 8.4% | 3/5 | flat/better | | search.first_query | p50 | 5.62 | 7.43 | +32.2% | 11.0% | 5/5 | SLOWER beyond noise | | startup.healthz | p50 | 5.55 | 5.05 | -9.1% | 47.2% | 0/5 | better | | open.api_get | p50 | 0.851 | 0.819 | -3.8% | 6.8% | 3/5 | better | | open.api_get | p95 | 3.89 | 4.61 | +18.5% | 238.4% | 4/5 | flat/better | | open.note | p50 | 0.947 | 0.851 | -10.1% | 16.3% | 2/5 | better | | open.note | p95 | 36.7 | 4.86 | -86.8% | 16.1% | 0/5 | better | ### Gate "search.query, open.note, cold_reconcile all <= dev" - `search.query` p50 3.34 -> 3.23 ms, p95 7.39 -> 7.48 ms: **flat** (inside the 7-8% spread). Pass. - `open.note` p50 -10%, p95 36.7 -> 4.9 ms: **pass** (dev p95 had a ~90 ms outlier in 3 of 10 arms). - `search.catch_up` 1.27 -> 0.85 s (-33%, 0/5 blocks worse): **better**. - `search.cold_reconcile` 45.6 -> 47.3 s (**+3.5%**, 5 of 5 blocks worse, spread 1.2%): **FAIL**, a steady ~+2 s. Likely the receipt-fence scan the rebuild now does before listing providers (`stage_source_fences`, then fence joins in `compare_page`); not yet profiled. - `search.first_query` p50 5.6 -> 7.4 ms (+32%, 5 of 5 blocks): mostly 4 of 10 candidate arms at 9.9-17.7 ms; the other arms are 5-7 ms like dev. Small in absolute terms but not flat: **FAIL** by the no-regression rule until explained. ### macOS flake `kill_nine_while_people_type_loses_and_doubles_nothing` (macos-01, same command, 20 runs each) - dev `9438918f3`: **20/20 pass**. - PR head: **2/20 fail** (13.6 s, `... never converged`, the rejoined-tab text check at `notes_crash_typing.rs:413`). Earlier PR runs: 1 of 1 and 2 of 10 failed. Pooled that is 5 failures in ~31 PR runs vs 0 in 20 on dev. - So I can no longer call it pre-existing on macOS. The PR changes the Notes room/publish path (`room/save.rs`, `room/mod.rs` `listed` now keyed by version, `meta.rs live_meta` gets `source_version`). Not diagnosed. ### State Liveness fix, tests and gap stage are pushed. Not mergeable: `cold_reconcile` and `first_query` regress, and the Mac flake looks PR-specific. Two follow-ups for a decision (the 3-round rule applies, so I am stopping here): 1. Profile the rebuild's fence scan on perf (`cold_reconcile` +2 s), then either speed it up or accept it as the cost of fenced receipts, with kayg's call since the rule is "no regression". 2. Bisect the Mac flake over the Notes-side commits (20 runs per step on macos-01). Also worth its own issue: `search.query` pays a fixed `frecent()` cost for any Home with 64+ used notes, on dev too. Cleanup: perf-01/perf-02 locks and units released, compute02 and perf-01 run data removed.
Author
Owner

P1b handoff to Codex (Claude usage limit), PR head 015546c00f9e3896a2088c89bc937ab5b36b5dcb

Pushed: everything is on the PR branch. Last commits: 015546c00 (crash-test fix), 2949f1e26 (first_query breakdown metrics), 3d5999c7a (gap stage opens 100 notes), ae2383a7d (50 ms catch-up poll). No perf lock, ticket or Mac lock held; my compute02 units are stopped.

1. macOS flake kill_nine_while_people_type…: found and fixed (test-only)

Mac runs, 20 each (re-run once at 11:13-11:16Z with no window announced in infraternal#260):

Code Test file Result
base 93d9a321a PR's rewritten test 4/20 fail, then 8/20 on re-run
PR head base's old test 0/20 fail
base 93d9a321a fixed test (015546c00) 20/20 pass, twice
PR head fixed test 20/20 pass, twice
Dev's old test passing 20/20 compared different test bodies. The PR's runtime code is not the cause. The fix moves the retrying notes.save before the first notes.get (as the original test did). The exact mechanism is likely the read racing the room's post-restart replay, not proven; the comment in the test says only what is established.

2. search.cold_reconcile +2 s (45.6 -> 47.3 s, 5/5 blocks): NOT fixed, profile not finished

  • Hypothesis: a cold rebuild has no cursor, so stage_source_fences (crates/search/src/indexer/sync.rs) scans the whole retained save-log (~200k entries at 100k notes) before listing; dev does no such scan.
  • I built a timing-only server (warn! lines PROF fence_scan, fence_scan_detail with journal-read vs record_fences ms, list_and_compare, attempt_total) from 3d5999c7a on compute02 (diff is uncommitted in ~/Developer/Worktrees/mail-1011-fix; it is 24 lines in sync.rs). Its first run was just launched and stopped, so there are no numbers yet.
  • Ideas that keep the fence semantics (need your design call): skip the per-entry item.clone() for entries with no fence (created entries), batch record_fences, or pipeline the scan with provider listing. A scan avoided only for a brand-new empty index would change semantics, so no.

3. search.first_query outliers: not explained yet

Candidate arms 4/10 at 9.9-17.7 ms vs 5-7 ms otherwise (dev 4.6-6.5). Queries use a pooled reader, so the first one opens a fresh connection (cold SQLite cache). 2949f1e26 adds search.first_query_sql (server took_ms), search.second_query and search.third_query to the harness, so the next ABAB separates SQL time from open/queue time. I did not test the cold-page-cache idea itself.

4. frecent() fixed cost: issue #1053

Evidence and the proposed top-64 in-memory cache are there. It explains the earlier 2x search.query (empty frecency table in the dev arm); harness fixed, search.query is now flat.

Next ABAB

Use plain perf-turn; the harness needs calternal-perf-fine rebuilt at 2949f1e26. Perf-02 handshake note: ssh from perf-01 to perf-02 fails inside systemd units, and my poller must not delete the runner's own ready file (it did, once).

## P1b handoff to Codex (Claude usage limit), PR head `015546c00f9e3896a2088c89bc937ab5b36b5dcb` Pushed: everything is on the PR branch. Last commits: `015546c00` (crash-test fix), `2949f1e26` (first_query breakdown metrics), `3d5999c7a` (gap stage opens 100 notes), `ae2383a7d` (50 ms catch-up poll). No perf lock, ticket or Mac lock held; my compute02 units are stopped. ### 1. macOS flake `kill_nine_while_people_type…`: found and fixed (test-only) Mac runs, 20 each (re-run once at 11:13-11:16Z with no window announced in infraternal#260): | Code | Test file | Result | |---|---|---| | base `93d9a321a` | PR's rewritten test | 4/20 fail, then 8/20 on re-run | | PR head | base's old test | 0/20 fail | | base `93d9a321a` | **fixed** test (`015546c00`) | 20/20 pass, twice | | PR head | **fixed** test | 20/20 pass, twice | Dev's old test passing 20/20 compared different test bodies. The PR's runtime code is not the cause. The fix moves the retrying `notes.save` before the first `notes.get` (as the original test did). The exact mechanism is likely the read racing the room's post-restart replay, not proven; the comment in the test says only what is established. ### 2. `search.cold_reconcile` +2 s (45.6 -> 47.3 s, 5/5 blocks): NOT fixed, profile not finished - Hypothesis: a cold rebuild has no cursor, so `stage_source_fences` (`crates/search/src/indexer/sync.rs`) scans the whole retained save-log (~200k entries at 100k notes) before listing; dev does no such scan. - I built a timing-only server (`warn!` lines `PROF fence_scan`, `fence_scan_detail` with journal-read vs `record_fences` ms, `list_and_compare`, `attempt_total`) from `3d5999c7a` on compute02 (diff is uncommitted in `~/Developer/Worktrees/mail-1011-fix`; it is 24 lines in `sync.rs`). Its first run was just launched and stopped, so there are no numbers yet. - Ideas that keep the fence semantics (need your design call): skip the per-entry `item.clone()` for entries with no fence (created entries), batch `record_fences`, or pipeline the scan with provider listing. A scan avoided only for a brand-new empty index would change semantics, so no. ### 3. `search.first_query` outliers: not explained yet Candidate arms 4/10 at 9.9-17.7 ms vs 5-7 ms otherwise (dev 4.6-6.5). Queries use a pooled reader, so the first one opens a fresh connection (cold SQLite cache). `2949f1e26` adds `search.first_query_sql` (server `took_ms`), `search.second_query` and `search.third_query` to the harness, so the next ABAB separates SQL time from open/queue time. I did not test the cold-page-cache idea itself. ### 4. `frecent()` fixed cost: issue #1053 Evidence and the proposed top-64 in-memory cache are there. It explains the earlier 2x `search.query` (empty `frecency` table in the dev arm); harness fixed, `search.query` is now flat. ### Next ABAB Use plain `perf-turn`; the harness needs `calternal-perf-fine` rebuilt at `2949f1e26`. Perf-02 handshake note: ssh from perf-01 to perf-02 fails inside systemd units, and my poller must not delete the runner's own `ready` file (it did, once).
Author
Owner

P1b follow-up evidence at head d83711c292701d3190e8c748c69827b21ab89a0e

Verdict: BLOCKED. The fixed macOS crash test is clean, but search.cold_reconcile remains slower than dev beyond the dev/dev control spread. I did not patch the PR because the remaining optimization needs a design decision about atomic full-reconcile staging.

Cold-reconcile profile and design note

I ran the existing calternal-perf harness on compute02 through ~/bin/slot with --sizes 100k --runs 1 --cold-runs 1 --gap-saves 600 --search-only --idle-secs 0. Two diagnostic runs took 114 s and 123 s; these compute02 timings are not perf-VM comparisons.

The timing-only build measured 391 provider pages. In the second run, the attempt took 82.130 s and final publish took 40.583 s (123 s total). The page breakdown was 1.365 s listing, 1.660 s comparing, and 78.578 s in document refresh/staging. Fence select took 46 ms; changed-item select took 86 ms. There was no pending-fence retry. The earlier fence-scan split measured 279 ms in journal reads, zero recorded fences, and 320 ms for the complete scan. The full save-log scan is not the source of the regression.

Design note for the orchestrator: the candidate's rebuild stages refreshed documents in a temporary SQLite table and then reads/deserializes them for one atomic publish. The evidence puts most candidate rebuild time in that stage/publish path. Removing that overhead while retaining pinned-source fence validation, bounded memory, old-index visibility until commit, and atomic document-plus-cursor publication needs a staging/publication design review. I stopped without a speculative code change; please choose the next design.

Perf ABAB x5, 100k

Five dev/candidate/dev/candidate blocks ran through the FIFO turn. All 20 arms passed. The dev-vs-dev column is the median relative gap between dev arms in a block.

Metric Stat Dev median Candidate median Delta Dev-vs-dev spread Candidate blocks worse
search.catch_up p50 1.293 s 0.813 s -37.132% 1.913% 0/5
search.cold_reconcile p50 45.372 s 47.383 s +4.433% 0.226% 5/5
search.query p50 3.165 ms 3.166 ms +0.035% 5.415% 3/5
search.query p95 6.888 ms 7.927 ms +15.085% 4.678% 5/5
search.first_query p50 5.266 ms 7.117 ms +35.157% 25.915% 3/5
search.first_query_server p50 4.739 ms 6.348 ms +33.967% 13.618% 4/5
startup.healthz p50 4.938 ms 4.909 ms -0.584% 3.738% 3/5
open.api_get p50 0.761 ms 0.846 ms +11.264% 6.198% 4/5
open.api_get p95 2.292 ms 4.693 ms +104.750% 59.002% 5/5
open.note p50 0.887 ms 0.932 ms +5.151% 4.737% 3/5
open.note p95 37.093 ms 4.912 ms -86.758% 13.126% 0/5

First-query outliers

Across ten candidate arms, first-query client time was 7.117 ms: 4.810 ms SQL, 1.483 ms server non-reader time, and 0.676 ms client non-server time. Second- and third-query SQL medians were 3.137 ms and 2.736 ms, with about 0.05 ms server remainder. Dev has no SQL timer; its first-query maxima were 11.188 ms server and 11.953 ms client, versus candidate maxima of 8.551 ms and 9.187 ms. The data points to first-reader/open/queue variation rather than SQL; it does not prove a PR-specific tail. The ABAB median is still +35.2%, so it remains unresolved under the no-regression rule.

macOS and other state

kill_nine_while_people_type_loses_and_doubles_nothing in crates/calternal/tests/notes_crash_typing.rs passed 20/20 twice on this head. The fix is test-only. The frecent() cost is tracked separately in #1053. The perf-02 hold was ours; PID 176135 was stopped and a follow-up check found both 176130 and 176135 absent.

## P1b follow-up evidence at head `d83711c292701d3190e8c748c69827b21ab89a0e` **Verdict: BLOCKED.** The fixed macOS crash test is clean, but `search.cold_reconcile` remains slower than dev beyond the dev/dev control spread. I did not patch the PR because the remaining optimization needs a design decision about atomic full-reconcile staging. ### Cold-reconcile profile and design note I ran the existing `calternal-perf` harness on compute02 through `~/bin/slot` with `--sizes 100k --runs 1 --cold-runs 1 --gap-saves 600 --search-only --idle-secs 0`. Two diagnostic runs took 114 s and 123 s; these compute02 timings are not perf-VM comparisons. The timing-only build measured 391 provider pages. In the second run, the attempt took 82.130 s and final publish took 40.583 s (123 s total). The page breakdown was 1.365 s listing, 1.660 s comparing, and 78.578 s in document refresh/staging. Fence select took 46 ms; changed-item select took 86 ms. There was no pending-fence retry. The earlier fence-scan split measured 279 ms in journal reads, zero recorded fences, and 320 ms for the complete scan. The full save-log scan is not the source of the regression. **Design note for the orchestrator:** the candidate's rebuild stages refreshed documents in a temporary SQLite table and then reads/deserializes them for one atomic publish. The evidence puts most candidate rebuild time in that stage/publish path. Removing that overhead while retaining pinned-source fence validation, bounded memory, old-index visibility until commit, and atomic document-plus-cursor publication needs a staging/publication design review. I stopped without a speculative code change; please choose the next design. ### Perf ABAB x5, 100k Five dev/candidate/dev/candidate blocks ran through the FIFO turn. All 20 arms passed. The dev-vs-dev column is the median relative gap between dev arms in a block. | Metric | Stat | Dev median | Candidate median | Delta | Dev-vs-dev spread | Candidate blocks worse | |---|---|---:|---:|---:|---:|---:| | `search.catch_up` | p50 | 1.293 s | 0.813 s | -37.132% | 1.913% | 0/5 | | `search.cold_reconcile` | p50 | 45.372 s | 47.383 s | +4.433% | 0.226% | 5/5 | | `search.query` | p50 | 3.165 ms | 3.166 ms | +0.035% | 5.415% | 3/5 | | `search.query` | p95 | 6.888 ms | 7.927 ms | +15.085% | 4.678% | 5/5 | | `search.first_query` | p50 | 5.266 ms | 7.117 ms | +35.157% | 25.915% | 3/5 | | `search.first_query_server` | p50 | 4.739 ms | 6.348 ms | +33.967% | 13.618% | 4/5 | | `startup.healthz` | p50 | 4.938 ms | 4.909 ms | -0.584% | 3.738% | 3/5 | | `open.api_get` | p50 | 0.761 ms | 0.846 ms | +11.264% | 6.198% | 4/5 | | `open.api_get` | p95 | 2.292 ms | 4.693 ms | +104.750% | 59.002% | 5/5 | | `open.note` | p50 | 0.887 ms | 0.932 ms | +5.151% | 4.737% | 3/5 | | `open.note` | p95 | 37.093 ms | 4.912 ms | -86.758% | 13.126% | 0/5 | ### First-query outliers Across ten candidate arms, first-query client time was 7.117 ms: 4.810 ms SQL, 1.483 ms server non-reader time, and 0.676 ms client non-server time. Second- and third-query SQL medians were 3.137 ms and 2.736 ms, with about 0.05 ms server remainder. Dev has no SQL timer; its first-query maxima were 11.188 ms server and 11.953 ms client, versus candidate maxima of 8.551 ms and 9.187 ms. The data points to first-reader/open/queue variation rather than SQL; it does not prove a PR-specific tail. The ABAB median is still +35.2%, so it remains unresolved under the no-regression rule. ### macOS and other state `kill_nine_while_people_type_loses_and_doubles_nothing` in `crates/calternal/tests/notes_crash_typing.rs` passed 20/20 twice on this head. The fix is test-only. The `frecent()` cost is tracked separately in #1053. The perf-02 hold was ours; PID 176135 was stopped and a follow-up check found both 176130 and 176135 absent.
Author
Owner

Approved cold-reconcile implementation plan (2026-11-11)

I will keep two fixed search-table generations behind a small meta.active_generation manifest. Reconcile lists and compares each provider page against the active generation, using the provider stamp as its content identity. Notes stamps are accepted-v1 BLAKE3 hashes. Unchanged documents are not fetched or staged. On the first changed or removed document, the writer copies the active indexed structures to the inactive set once, then applies changed documents and removals in bounded batches as each provider page is staged. An empty first-build index starts with an empty inactive set.

The FTS tables stay separate per generation so the hidden build cannot change BM25 corpus statistics or query results. Searches read the manifest inside their existing SQLite read transaction and stay on one generation. Receipt fences, pinned provider snapshot validation, and journal-head validation remain required before publication. The final transaction updates only the active-generation pointer and the cursor/page-start metadata; an interrupted build leaves the old manifest and cursor intact, and retry resets the inactive set.

Bounds and cost

  • Provider and receipt pages remain at most 256 rows; document fetch batches remain at most 64; compare metadata remains at most 512; SQLite writer cache remains 2,000 KiB.
  • RAM remains O(256 + 64 + 512) independent of Home size. The inactive search generation uses O(M) disk for M indexed rows. Existing indexes need one full SQLite-side copy on the first changed page; cold empty indexes skip that copy. Refresh work is proportional to changed content, not all listed documents. The listing/fence path remains O(K + N log M + M).
  • No provider document is JSON-serialized into a full-reconcile spool and deserialized for a second indexing pass. Each changed document is indexed once into the hidden generation.
Failure Effect Detection Recovery Test
Crash during a staged provider page Partial rows exist only in the inactive generation Active manifest and cursor still name the old generation Reset inactive generation and repeat reconcile Hidden-page visibility and restart convergence
Receipt is ahead of pinned source Candidate generation is not publishable Existing source-version fence comparison Keep old generation, wait/retry under the existing cap Existing delayed-publication and superseded-fence tests
Provider snapshot changes during scan Candidate rows may not describe one provider view Existing snapshot validation Keep old generation and retry from a fresh snapshot Existing snapshot-change property test
Journal target expires during scan Candidate cursor cannot be trusted Engine::position before publication Keep old cursor and reconcile from the valid head Existing restored/truncated cursor tests
Crash during final publication Documents and cursor could disagree only if the transaction were split SQLite transaction covers pointer plus cursor metadata Recovery sees either old or new manifest/cursor together Cursor publication and restart tests

The qualification remains ABAB ×5 against dev with dev-vs-dev control bounds, plus the macOS crash test ×20. Every reported metric must be no worse than its control bound.

## Approved cold-reconcile implementation plan (2026-11-11) I will keep two fixed search-table generations behind a small `meta.active_generation` manifest. Reconcile lists and compares each provider page against the active generation, using the provider stamp as its content identity. Notes stamps are `accepted-v1` BLAKE3 hashes. Unchanged documents are not fetched or staged. On the first changed or removed document, the writer copies the active indexed structures to the inactive set once, then applies changed documents and removals in bounded batches as each provider page is staged. An empty first-build index starts with an empty inactive set. The FTS tables stay separate per generation so the hidden build cannot change BM25 corpus statistics or query results. Searches read the manifest inside their existing SQLite read transaction and stay on one generation. Receipt fences, pinned provider snapshot validation, and journal-head validation remain required before publication. The final transaction updates only the active-generation pointer and the cursor/page-start metadata; an interrupted build leaves the old manifest and cursor intact, and retry resets the inactive set. ### Bounds and cost - Provider and receipt pages remain at most 256 rows; document fetch batches remain at most 64; compare metadata remains at most 512; SQLite writer cache remains 2,000 KiB. - RAM remains `O(256 + 64 + 512)` independent of Home size. The inactive search generation uses `O(M)` disk for `M` indexed rows. Existing indexes need one full SQLite-side copy on the first changed page; cold empty indexes skip that copy. Refresh work is proportional to changed content, not all listed documents. The listing/fence path remains `O(K + N log M + M)`. - No provider document is JSON-serialized into a full-reconcile spool and deserialized for a second indexing pass. Each changed document is indexed once into the hidden generation. | Failure | Effect | Detection | Recovery | Test | |---|---|---|---|---| | Crash during a staged provider page | Partial rows exist only in the inactive generation | Active manifest and cursor still name the old generation | Reset inactive generation and repeat reconcile | Hidden-page visibility and restart convergence | | Receipt is ahead of pinned source | Candidate generation is not publishable | Existing source-version fence comparison | Keep old generation, wait/retry under the existing cap | Existing delayed-publication and superseded-fence tests | | Provider snapshot changes during scan | Candidate rows may not describe one provider view | Existing snapshot validation | Keep old generation and retry from a fresh snapshot | Existing snapshot-change property test | | Journal target expires during scan | Candidate cursor cannot be trusted | `Engine::position` before publication | Keep old cursor and reconcile from the valid head | Existing restored/truncated cursor tests | | Crash during final publication | Documents and cursor could disagree only if the transaction were split | SQLite transaction covers pointer plus cursor metadata | Recovery sees either old or new manifest/cursor together | Cursor publication and restart tests | The qualification remains ABAB ×5 against dev with dev-vs-dev control bounds, plus the macOS crash test ×20. Every reported metric must be no worse than its control bound.
Author
Owner

P1b qualification status at c5ad7946ee9b52bc3dd3bde50fe9638ad84e2fc1 — BLOCKED

The approved two-generation incremental reconcile redesign is pushed on this PR branch. The following table is the last valid ABAB ×5 evidence before that redesign, from d83711c292701d3190e8c748c69827b21ab89a0e; it is not a qualification result for the current head. No post-redesign ABAB or Mac ×20 result was collected.

Metric Stat Dev median Candidate median Delta Dev/dev spread Candidate blocks worse
search.catch_up p50 1.293 s 0.813 s -37.132% 1.913% 0/5
search.cold_reconcile p50 45.372 s 47.383 s +4.433% 0.226% 5/5
search.query p50 3.165 ms 3.166 ms +0.035% 5.415% 3/5
search.query p95 6.888 ms 7.927 ms +15.085% 4.678% 5/5
search.first_query p50 5.266 ms 7.117 ms +35.157% 25.915% 3/5
search.first_query_server p50 4.739 ms 6.348 ms +33.967% 13.618% 4/5
startup.healthz p50 4.938 ms 4.909 ms -0.584% 3.738% 3/5
open.api_get p50 0.761 ms 0.846 ms +11.264% 6.198% 4/5
open.api_get p95 2.292 ms 4.693 ms +104.750% 59.002% 5/5
open.note p50 0.887 ms 0.932 ms +5.151% 4.737% 3/5
open.note p95 37.093 ms 4.912 ms -86.758% 13.126% 0/5

Known cause and outstanding query attribution

The cold-reconcile profile found 78.578 s in staged document refresh and 40.583 s in the final publish transaction (82.130 s attempt time before publish). The full receipt-fence scan was 320 ms, so it was not the source of the cold-reconcile regression. The approved redesign addresses the measured staging/publish path by skipping unchanged content hashes, applying changed pages into an inactive generation, and switching only the small manifest with the cursor.

The candidate first-query breakdown was 4.810 ms SQL, 1.483 ms server time outside SQL, and 0.676 ms client time outside the server. Second/third-query SQL medians were 3.137/2.736 ms. That points toward open/queue variation, but it did not prove a PR-specific cause. The current head has no new split metrics, so query/first-query are unverified.

Why qualification stopped

After more than three hours of foreground waiting, perf-01 was still held by the rows B3 run (with editor typing queued), and the Mac lock was held by a Safari run. No current-head measurement started. The earlier crash test was 20/20 twice on the pre-redesign head; the required ×20 rerun at this head did not run.

## P1b qualification status at `c5ad7946ee9b52bc3dd3bde50fe9638ad84e2fc1` — BLOCKED The approved two-generation incremental reconcile redesign is pushed on this PR branch. The following table is the **last valid ABAB ×5 evidence before that redesign**, from `d83711c292701d3190e8c748c69827b21ab89a0e`; it is not a qualification result for the current head. No post-redesign ABAB or Mac ×20 result was collected. | Metric | Stat | Dev median | Candidate median | Delta | Dev/dev spread | Candidate blocks worse | |---|---|---:|---:|---:|---:|---:| | `search.catch_up` | p50 | 1.293 s | 0.813 s | -37.132% | 1.913% | 0/5 | | `search.cold_reconcile` | p50 | 45.372 s | 47.383 s | +4.433% | 0.226% | 5/5 | | `search.query` | p50 | 3.165 ms | 3.166 ms | +0.035% | 5.415% | 3/5 | | `search.query` | p95 | 6.888 ms | 7.927 ms | +15.085% | 4.678% | 5/5 | | `search.first_query` | p50 | 5.266 ms | 7.117 ms | +35.157% | 25.915% | 3/5 | | `search.first_query_server` | p50 | 4.739 ms | 6.348 ms | +33.967% | 13.618% | 4/5 | | `startup.healthz` | p50 | 4.938 ms | 4.909 ms | -0.584% | 3.738% | 3/5 | | `open.api_get` | p50 | 0.761 ms | 0.846 ms | +11.264% | 6.198% | 4/5 | | `open.api_get` | p95 | 2.292 ms | 4.693 ms | +104.750% | 59.002% | 5/5 | | `open.note` | p50 | 0.887 ms | 0.932 ms | +5.151% | 4.737% | 3/5 | | `open.note` | p95 | 37.093 ms | 4.912 ms | -86.758% | 13.126% | 0/5 | ### Known cause and outstanding query attribution The cold-reconcile profile found 78.578 s in staged document refresh and 40.583 s in the final publish transaction (82.130 s attempt time before publish). The full receipt-fence scan was 320 ms, so it was not the source of the cold-reconcile regression. The approved redesign addresses the measured staging/publish path by skipping unchanged content hashes, applying changed pages into an inactive generation, and switching only the small manifest with the cursor. The candidate first-query breakdown was 4.810 ms SQL, 1.483 ms server time outside SQL, and 0.676 ms client time outside the server. Second/third-query SQL medians were 3.137/2.736 ms. That points toward open/queue variation, but it did not prove a PR-specific cause. The current head has no new split metrics, so query/first-query are unverified. ### Why qualification stopped After more than three hours of foreground waiting, perf-01 was still held by the rows B3 run (with editor typing queued), and the Mac lock was held by a Safari run. No current-head measurement started. The earlier crash test was 20/20 twice on the pre-redesign head; the required ×20 rerun at this head did not run.
Author
Owner

BLOCKED — head c5ad7946ee9b52bc3dd3bde50fe9638ad84e2fc1

The branch is pushed. Current-head ABAB ×5 and macOS crash ×20 remain unrun after more than three hours waiting on shared locks. The last valid cold-reconcile result on the previous head was 47.383 s vs 45.372 s on dev (+4.433%; dev/dev spread 0.226%). Its profile attributed 78.578 s to staged document refresh and 40.583 s to final publish. That evidence predates the pushed redesign and does not qualify this head. See the preceding comment for the full prior metric table and query-breakdown evidence.

**BLOCKED — head `c5ad7946ee9b52bc3dd3bde50fe9638ad84e2fc1`** The branch is pushed. Current-head ABAB ×5 and macOS crash ×20 remain unrun after more than three hours waiting on shared locks. The last valid cold-reconcile result on the previous head was 47.383 s vs 45.372 s on dev (+4.433%; dev/dev spread 0.226%). Its profile attributed 78.578 s to staged document refresh and 40.583 s to final publish. That evidence predates the pushed redesign and does not qualify this head. See the preceding comment for the full prior metric table and query-breakdown evidence.
Author
Owner

Mail #1011 handover, 13 Nov 2026 (written by the orchestrator; the lane was stopped before it could post its own)

Heads

  • PR #1011 branch t3/paged-search-reconcile-final: 326e3cab580e. This contains the approved two-generation incremental reconcile redesign (plan, comment 90887).
  • A later diagnostic candidate on dev-01 (mail1011-recovery-candidate-927fe80-20261112, head e6db46203174, 22 commits beyond the remote) is pushed as wip/handover/mail1011-candidate. It adds SQL, reader-open and queue timing splits to the perf harness (56 metrics vs dev's 32). Check whether it holds any product fixes beyond the PR head before deciding what to keep.

Gates on 326e3cab

  • macOS crash test: 20/20 pass, on 11-13.
  • Perf ABAB ×5 at 100k on perf-01, started 14:03 IST on 11-13:
    • All 20 arms are recorded under ~/Developer/Worktrees/mail1011-perf-326e3-20261113.Kiq4rT on perf-01. Every arm the lane reported on passed the harness.
    • The run was interrupted at the final dev arm (b5-d2). The results have not been analysed yet.
    • Next step: compare them against dev, including the dev/dev spread. Treat b5-d2 as possibly incomplete and check its report.

Last valid result before the redesign (head d83711c2, comment 91798):

Metric vs dev dev/dev spread
search.cold_reconcile p50 +4.4% 0.23%
search.query p95 +15%
search.first_query +35%
open.api_get p95 +105%
search.catch_up −37%

The redesign targets the staging/publish path, which took 78.6 s refresh + 40.6 s publish in that profile.

Next steps

  1. Analyse the 326e3cab ABAB, using the same comparator as before.
  2. If cold reconcile and query p95 are at or below dev, mark READY.
  3. If not, profile the remaining query-latency regressions (first_query, api_get p95).
## Mail #1011 handover, 13 Nov 2026 (written by the orchestrator; the lane was stopped before it could post its own) **Heads** - PR #1011 branch `t3/paged-search-reconcile-final`: `326e3cab580e`. This contains the approved two-generation incremental reconcile redesign ([plan, comment 90887](https://git.kayg.org/kayg/calternal/pulls/1011#issuecomment-90887)). - A later diagnostic candidate on dev-01 (`mail1011-recovery-candidate-927fe80-20261112`, head `e6db46203174`, 22 commits beyond the remote) is pushed as **`wip/handover/mail1011-candidate`**. It adds SQL, reader-open and queue timing splits to the perf harness (56 metrics vs dev's 32). Check whether it holds any product fixes beyond the PR head before deciding what to keep. **Gates on `326e3cab`** - macOS crash test: **20/20 pass**, on 11-13. - Perf ABAB ×5 at 100k on perf-01, started 14:03 IST on 11-13: - All 20 arms are recorded under `~/Developer/Worktrees/mail1011-perf-326e3-20261113.Kiq4rT` on perf-01. Every arm the lane reported on passed the harness. - The run was interrupted at the final dev arm (`b5-d2`). **The results have not been analysed yet.** - Next step: compare them against dev, including the dev/dev spread. Treat `b5-d2` as possibly incomplete and check its report. **Last valid result before the redesign** (head `d83711c2`, [comment 91798](https://git.kayg.org/kayg/calternal/pulls/1011#issuecomment-91798)): | Metric | vs dev | dev/dev spread | |---|---|---| | `search.cold_reconcile` p50 | +4.4% | 0.23% | | `search.query` p95 | +15% | | | `search.first_query` | +35% | | | `open.api_get` p95 | +105% | | | `search.catch_up` | −37% | | The redesign targets the staging/publish path, which took 78.6 s refresh + 40.6 s publish in that profile. **Next steps** 1. Analyse the 326e3cab ABAB, using the same comparator as before. 2. If cold reconcile and query p95 are at or below dev, mark READY. 3. If not, profile the remaining query-latency regressions (`first_query`, `api_get` p95).
Author
Owner

Analysis of the 326e3cab ABAB ×5 (100k, perf-01): NOT READY

Head 326e3cab580e. Merge dry run onto current origin/dev (796d80cba): clean, no conflicts (git merge-tree --write-tree, nothing pushed, not merged).

Data check. 20/20 arms exit 0, no harness failures, 100000 notes each. The interrupted-looking b5-d2 is complete (exit 0, json+md written, 32 metrics, failures: [], perf-run-complete present), so all 20 arms are included. Binaries on perf-01 (sha256): dev 29a914ff…7361, candidate 7efff113…ed7.

Comparator (same as comment 91798): per block, the dev value is the mean of the two dev arms and the candidate value the mean of the two candidate arms. The table uses the median over the 5 blocks. Spread is the median over blocks of |d1−d2| / mean (dev/dev). "Worse" counts blocks where the candidate is slower than dev.

Metric Stat Dev Cand Delta Dev/dev spread Worse
search.cold_reconcile p50 27.64 s 34.78 s +25.8% 0.5% 5/5
search.query p50 3.066 ms 3.380 ms +10.3% 7.2% 5/5
search.query p95 6.772 ms 7.272 ms +7.4% 5.9% 5/5
search.query_server p50 / p95 2.670 / 6.313 ms 2.992 / 6.772 ms +12.1% / +7.3% 1.6% / 5.6% 5/5
search.first_query p50 5.703 ms 6.022 ms +5.6% 19.2% 4/5 (inside spread)
search.first_query_server p50 4.936 ms 5.485 ms +11.1% 22.6% 4/5 (inside spread)
search.second_query p50 2.916 ms 3.788 ms +29.9% 7.5% 5/5
search.third_query p50 3.248 ms 3.624 ms +11.6% 9.9% 3/5 (inside spread)
search.prefix p50 / p95 2.798 / 3.832 ms 2.984 / 5.515 ms +6.6% / +43.9% 5.0% / 3.9% 5/5
search.catch_up p50 448 ms 4.0 ms −99.1% 1.1% 0/5
open.api_get p50 / p95 0.789 / 6.346 ms 0.838 / 4.618 ms +6.3% / −27.2% 7.7% / 54.6% 3/5 / 1/5 (OK)
open.note p50 / p95 0.910 / 4.794 ms 0.965 / 4.628 ms +6.1% / −3.5% 13.0% / 41.3% OK
startup.healthz p50 5.232 ms 5.368 ms +2.6% 11.0% OK
cold.index p50 15.88 s 16.62 s +4.7% 1.7% 5/5
cold.first_page p50 1860 ms 1925 ms +3.5% 2.3% 4/5 (inside spread)
cold.disk_written p50 1920 MB 1999 MB +4.1% 0.0% 5/5
cold.mem_peak p50 294.5 MB 297.2 MB +0.9% 1.2% OK
search.typo p50 / p95 5.468 / 23.71 ms 1.687 / 12.31 ms −69% / −48% 66% / 31% better (large spread)

Also better, no regression: cold.startup, home.first_page, mem.after_search, mem.after_first_page, shutdown (314 → 22 ms; spreads of 30–50% mean treat these as noisy). Full per-metric output is on request; the second/third_query_*_client_non_server and query_client_non_server p50/p95 are all +5–59%, mostly sub-ms.

Not covered: sync.save_ack and notes_save are not in this run. The harness ran --search-only, so the save scenarios were not measured. The run has no budget gate for the search metrics.

Verdict

Cold reconcile and query p95 are both outside the dev/dev spread, and all of search.query, query_server, second_query, prefix and cold.index are worse in 5/5 blocks. Merging now would be a perf regression.

  • Cold reconcile is worse than before the redesign in relative terms (+25.8%, was +4.4% at d83711c2), although it is faster in absolute terms (34.8 s against 47.4 s).
  • Query regressions sit in SQL. Candidate-only splits (medians over 10 candidate arms): search.query is 3.38 ms total, 2.99 ms server, 2.93 ms SQL, reader open 0.000, index open 0.000, blocking queue 0.015, non-reader server time 0.051, client outside server 0.41. So the extra time is not the queue, reader open or HTTP. It is the SQL itself (second/third query: 3.11/2.94 ms SQL). First query: 4.51 ms SQL, 0.27 ms reader open, 0.79 ms index open, 1.18 ms non-reader server time, so the cold-open costs are small next to SQL. Dev has no split metrics, so SQL-vs-dev is inferred from query_server (+0.32 ms), not measured directly.
  • Likely cause: the same FTS5 queries now run on the generation tables after an incremental build. cold.index (+4.7%) and cold.disk_written (+79 MB) point at a heavier or less compact build, and FTS5 segments of a staged index may not be merged the way dev's single pass leaves them. This is a hypothesis; confirm with a segment/page count of the active FTS table in both arms.

Proposed next fix

  1. wip/handover/mail1011-candidate (e6db46203, merge base with this PR 437f9ec89) holds product changes the PR head lacks, all aimed at the cold-reconcile cost: 8dd871851 batch reconcile provider pages, 2a1502cc3 batch pinned source reads, 323083d44 batch content comparisons, 927fe80bd defer reconcile scratch tables, 86f821b68 skip redundant cold-reconcile lookups. They touch crates/search/src/{write,indexer,index}.rs and crates/notes/src/generation.rs. Rebase these onto the PR (it also has later commits the wip branch lacks, e.g. 777f08264) and re-run ABAB; cold reconcile is the most likely win.
  2. For the query path: run the optimize/merge step (FTS5 optimize or merge) on the new generation before publishing, or at least on the first publish, and confirm with the segment counts above. If equal, compare EXPLAIN QUERY PLAN on the generation-table queries against dev's (an extra manifest join or per-query table-name resolution would show there).
  3. The next ABAB should add the save scenarios (sync.save_ack) and a dev-vs-dev control pair at the start and end, as docs/perf/comparing.md requires. This run had no separate control pair beyond the within-block d1/d2 spread above.

No ticket or lock was taken; the run was read-only (results copied to a scratch dir on hd01).

## Analysis of the 326e3cab ABAB ×5 (100k, perf-01): **NOT READY** Head `326e3cab580e`. Merge dry run onto current `origin/dev` (`796d80cba`): **clean, no conflicts** (`git merge-tree --write-tree`, nothing pushed, not merged). **Data check.** 20/20 arms exit 0, no harness failures, 100000 notes each. The interrupted-looking `b5-d2` is complete (exit 0, json+md written, 32 metrics, `failures: []`, `perf-run-complete` present), so **all 20 arms are included**. Binaries on perf-01 (sha256): dev `29a914ff…7361`, candidate `7efff113…ed7`. **Comparator** (same as comment 91798): per block, the dev value is the mean of the two dev arms and the candidate value the mean of the two candidate arms. The table uses the median over the 5 blocks. Spread is the median over blocks of |d1−d2| / mean (dev/dev). "Worse" counts blocks where the candidate is slower than dev. | Metric | Stat | Dev | Cand | Delta | Dev/dev spread | Worse | |---|---|---:|---:|---:|---:|---:| | `search.cold_reconcile` | p50 | 27.64 s | 34.78 s | **+25.8%** | 0.5% | 5/5 | | `search.query` | p50 | 3.066 ms | 3.380 ms | **+10.3%** | 7.2% | 5/5 | | `search.query` | p95 | 6.772 ms | 7.272 ms | **+7.4%** | 5.9% | 5/5 | | `search.query_server` | p50 / p95 | 2.670 / 6.313 ms | 2.992 / 6.772 ms | **+12.1% / +7.3%** | 1.6% / 5.6% | 5/5 | | `search.first_query` | p50 | 5.703 ms | 6.022 ms | +5.6% | 19.2% | 4/5 (inside spread) | | `search.first_query_server` | p50 | 4.936 ms | 5.485 ms | +11.1% | 22.6% | 4/5 (inside spread) | | `search.second_query` | p50 | 2.916 ms | 3.788 ms | **+29.9%** | 7.5% | 5/5 | | `search.third_query` | p50 | 3.248 ms | 3.624 ms | +11.6% | 9.9% | 3/5 (inside spread) | | `search.prefix` | p50 / p95 | 2.798 / 3.832 ms | 2.984 / 5.515 ms | **+6.6% / +43.9%** | 5.0% / 3.9% | 5/5 | | `search.catch_up` | p50 | 448 ms | 4.0 ms | −99.1% | 1.1% | 0/5 | | `open.api_get` | p50 / p95 | 0.789 / 6.346 ms | 0.838 / 4.618 ms | +6.3% / −27.2% | 7.7% / 54.6% | 3/5 / 1/5 (OK) | | `open.note` | p50 / p95 | 0.910 / 4.794 ms | 0.965 / 4.628 ms | +6.1% / −3.5% | 13.0% / 41.3% | OK | | `startup.healthz` | p50 | 5.232 ms | 5.368 ms | +2.6% | 11.0% | OK | | `cold.index` | p50 | 15.88 s | 16.62 s | **+4.7%** | 1.7% | 5/5 | | `cold.first_page` | p50 | 1860 ms | 1925 ms | +3.5% | 2.3% | 4/5 (inside spread) | | `cold.disk_written` | p50 | 1920 MB | 1999 MB | +4.1% | 0.0% | 5/5 | | `cold.mem_peak` | p50 | 294.5 MB | 297.2 MB | +0.9% | 1.2% | OK | | `search.typo` | p50 / p95 | 5.468 / 23.71 ms | 1.687 / 12.31 ms | −69% / −48% | 66% / 31% | better (large spread) | Also better, no regression: `cold.startup`, `home.first_page`, `mem.after_search`, `mem.after_first_page`, `shutdown` (314 → 22 ms; spreads of 30–50% mean treat these as noisy). Full per-metric output is on request; the `second/third_query_*_client_non_server` and `query_client_non_server` p50/p95 are all +5–59%, mostly sub-ms. Not covered: `sync.save_ack` and `notes_save` are not in this run. The harness ran `--search-only`, so the save scenarios were not measured. The run has no budget gate for the search metrics. ### Verdict Cold reconcile and query p95 are both outside the dev/dev spread, and all of `search.query`, `query_server`, `second_query`, `prefix` and `cold.index` are worse in 5/5 blocks. Merging now would be a perf regression. - **Cold reconcile is worse than before the redesign in relative terms** (+25.8%, was +4.4% at `d83711c2`), although it is faster in absolute terms (34.8 s against 47.4 s). - **Query regressions sit in SQL.** Candidate-only splits (medians over 10 candidate arms): `search.query` is 3.38 ms total, 2.99 ms server, **2.93 ms SQL**, reader open 0.000, index open 0.000, blocking queue 0.015, non-reader server time 0.051, client outside server 0.41. So the extra time is not the queue, reader open or HTTP. It is the SQL itself (second/third query: 3.11/2.94 ms SQL). First query: 4.51 ms SQL, 0.27 ms reader open, 0.79 ms index open, 1.18 ms non-reader server time, so the cold-open costs are small next to SQL. Dev has no split metrics, so SQL-vs-dev is inferred from `query_server` (+0.32 ms), not measured directly. - Likely cause: the same FTS5 queries now run on the generation tables after an incremental build. `cold.index` (+4.7%) and `cold.disk_written` (+79 MB) point at a heavier or less compact build, and FTS5 segments of a staged index may not be merged the way dev's single pass leaves them. This is a hypothesis; confirm with a segment/page count of the active FTS table in both arms. ### Proposed next fix 1. `wip/handover/mail1011-candidate` (`e6db46203`, merge base with this PR `437f9ec89`) holds **product changes the PR head lacks**, all aimed at the cold-reconcile cost: `8dd871851` batch reconcile provider pages, `2a1502cc3` batch pinned source reads, `323083d44` batch content comparisons, `927fe80bd` defer reconcile scratch tables, `86f821b68` skip redundant cold-reconcile lookups. They touch `crates/search/src/{write,indexer,index}.rs` and `crates/notes/src/generation.rs`. Rebase these onto the PR (it also has later commits the wip branch lacks, e.g. `777f08264`) and re-run ABAB; cold reconcile is the most likely win. 2. For the query path: run the optimize/merge step (FTS5 `optimize` or `merge`) on the new generation before publishing, or at least on the first publish, and confirm with the segment counts above. If equal, compare `EXPLAIN QUERY PLAN` on the generation-table queries against dev's (an extra manifest join or per-query table-name resolution would show there). 3. The next ABAB should add the save scenarios (`sync.save_ack`) and a dev-vs-dev control pair at the start and end, as `docs/perf/comparing.md` requires. This run had no separate control pair beyond the within-block d1/d2 spread above. No ticket or lock was taken; the run was read-only (results copied to a scratch dir on hd01).
Author
Owner

#1011 perf-neutral pass, interim status (head be4f42562). NOT READY yet: perf ABAB queued

Pushed to t3/paged-search-reconcile-final (fast-forward from 326e3cab5; also on wip/mail1011-perfneutral). No merge.

What the 326e3 regressions turned out to be (diagnosed on compute02; these timings are not gate numbers)

  • Step 1 (port from wip/handover/mail1011-candidate) was already done: the PR head carries rebased copies of 8dd871851, 2a1502cc3, 323083d44, 927fe80bd, 86f821b68 (identical diffs or context-adjusted, with the fetch fixups folded into indexer/fetch.rs). The 326e3 ABAB already measured them.
  • Query SQL is not slower. On a 100k index, the same Index::search code on the dev index, PR code on a dev-shaped index, and PR code on the PR index time within noise (p50 5.3–5.5 ms each, interleaved ×3). FTS5 shape is close: fts 29 vs 30 segments, titles 12 vs 19, tri 6 vs 9, data 345.8 MB both. On a live server after background work settles, the PR's server-side p50 is 3.45 ms vs dev 3.60 ms. No optimize or plan change needed; prefix indexes are intact (same prefix='2 3' DDL).
  • The harness query delta was startup work landing in the measured window. The typo vocabulary (0.7–1.6 s of CPU at 100k) was built lazily by the first few-result search. In the PR it started later and was still running in the query and typo phases. That is why search.typo looked 69% faster: the PR's typo searches got no correction (corrected empty for every typo query in the warm run; dev corrected all of them). Fix: build the vocabulary in the background once the index has caught up (eb463d5aa). I tried pacing the catch-up too and reverted it (3efa9bc6c): it pushed the catch-up and vocab into the query window.
  • Cold reconcile: writer CPU was not higher than dev's. The build took turns: list → compare → fetch → write per page, so the writer was busy only 55–70% of the time. Fix: write page N while page N+1 is read; the compare is sent before the write so it never queues behind it (079c5377d, at most two pages of documents held). Also, cold_reconcile stops when search reports ready. Dev checkpoints its big WAL after that point; the PR checkpointed every 64 writer jobs during the build. The periodic checkpoint now waits while a hidden generation builds (be4f42562). A one-transaction-per-64-pages variant didn't lower writer CPU, so it's reverted (f3238cc06 / b31b2944a).
  • cold.index +4.7%, cold.disk_written +79 MB: the PR's new source_updated_id (updated, id) index was maintained row by row during a fresh 100k fill. It now joins FRESH_DROPS and is built once at the end (c09539475); disk written is back within ~10 MB of dev.

Bugs found and fixed on the way (all failing at 326e3cab5)

  • Archive never left search: archive's executor receipt carries a known source_version, but the archived note fetches as absent, so the fence never cleared (note_visibility timed out). Added SearchProvider::fence_version (default None; Notes reads the pinned row whatever its searchability). It's read only for removed rows under a known fence (9b2b7db3d).
  • search/tests/hidden_blocks_upgrade.rs didn't compile (no list_page); opening.rs expected the wrong index count; search_live asserted perf-only timing fields; strict clippy failed in four places. All fixed.
  • Harness: --search-only now also runs the typing round trip, so sync.save_ack / notes.save are measured (4dc666057).

Gates at be4f42562

Gate Command Result
fmt cargo fmt --all --check (dev-01, slot) PASS
clippy strict cargo clippy -j4 --workspace --all-targets --locked -- -D warnings PASS (0 errors/warnings)
workspace tests cargo test -j4 --workspace --locked --no-fail-fast (after bun install --frozen-lockfile) 1,837 passed, 0 failed, 22 ignored
crash, Linux cargo test -p calternal --test notes_crash_typing kill_nine_while_people_type_loses_and_doubles_nothing -- --exact ×20, interleaved with dev 796d80cba PR 20/20, dev 20/20
crash, macOS same ×20 on macos-01 under /tmp/mac-bench.lock 20/20
Chromium e2e (dev-01) bunx playwright test e2e/{search-palette,search-corpus,editor,list-catch-up,list-search,trash-search,visibility}.spec.ts --project=chromium-1440 --project=chromium-390 --workers=1 77 passed, 39 skipped, 0 failed
WebKit e2e (dev-02) same specs, --project=webkit-1440 --project=webkit-390 70 passed, 46 skipped, 0 failed

Perf

Binaries staged on perf-01 and sha256-verified at both ends: dev 796d80cba bbe582a2…6dc, candidate be4f42562 179dc4d1…9c9, harness b4989808…46d. Session: control pair, ABAB ×5, control pair, 100k, --search-only --gap-saves 600. Ticket re-queued behind s4h-1100 as the orchestrator asked. perf-01 couldn't reach perf-02 over NetBird (DNS failure, then connection refused), so perf-02's lock is now taken from hd01. Results to follow in the next comment.

## #1011 perf-neutral pass, interim status (head `be4f42562`). NOT READY yet: perf ABAB queued Pushed to `t3/paged-search-reconcile-final` (fast-forward from `326e3cab5`; also on `wip/mail1011-perfneutral`). No merge. ### What the 326e3 regressions turned out to be (diagnosed on compute02; these timings are not gate numbers) - **Step 1 (port from `wip/handover/mail1011-candidate`)** was already done: the PR head carries rebased copies of `8dd871851`, `2a1502cc3`, `323083d44`, `927fe80bd`, `86f821b68` (identical diffs or context-adjusted, with the fetch fixups folded into `indexer/fetch.rs`). The 326e3 ABAB already measured them. - **Query SQL is not slower.** On a 100k index, the same `Index::search` code on the dev index, PR code on a dev-shaped index, and PR code on the PR index time within noise (p50 5.3–5.5 ms each, interleaved ×3). FTS5 shape is close: fts 29 vs 30 segments, titles 12 vs 19, tri 6 vs 9, data 345.8 MB both. On a live server after background work settles, the PR's server-side p50 is 3.45 ms vs dev 3.60 ms. No `optimize` or plan change needed; prefix indexes are intact (same `prefix='2 3'` DDL). - **The harness query delta was startup work landing in the measured window.** The typo vocabulary (0.7–1.6 s of CPU at 100k) was built lazily by the first few-result search. In the PR it started later and was still running in the query and typo phases. That is why `search.typo` looked 69% *faster*: the PR's typo searches got **no correction** (`corrected` empty for every typo query in the warm run; dev corrected all of them). Fix: build the vocabulary in the background once the index has caught up (`eb463d5aa`). I tried pacing the catch-up too and reverted it (`3efa9bc6c`): it pushed the catch-up and vocab into the query window. - **Cold reconcile:** writer CPU was not higher than dev's. The build took turns: list → compare → fetch → write per page, so the writer was busy only 55–70% of the time. Fix: write page N while page N+1 is read; the compare is sent before the write so it never queues behind it (`079c5377d`, at most two pages of documents held). Also, `cold_reconcile` stops when search reports ready. Dev checkpoints its big WAL *after* that point; the PR checkpointed every 64 writer jobs *during* the build. The periodic checkpoint now waits while a hidden generation builds (`be4f42562`). A one-transaction-per-64-pages variant didn't lower writer CPU, so it's reverted (`f3238cc06` / `b31b2944a`). - **`cold.index` +4.7%, `cold.disk_written` +79 MB:** the PR's new `source_updated_id (updated, id)` index was maintained row by row during a fresh 100k fill. It now joins `FRESH_DROPS` and is built once at the end (`c09539475`); disk written is back within ~10 MB of dev. ### Bugs found and fixed on the way (all failing at `326e3cab5`) - Archive never left search: archive's executor receipt carries a known `source_version`, but the archived note fetches as absent, so the fence never cleared (`note_visibility` timed out). Added `SearchProvider::fence_version` (default `None`; Notes reads the pinned row whatever its searchability). It's read only for removed rows under a known fence (`9b2b7db3d`). - `search/tests/hidden_blocks_upgrade.rs` didn't compile (no `list_page`); `opening.rs` expected the wrong index count; `search_live` asserted perf-only timing fields; strict clippy failed in four places. All fixed. - Harness: `--search-only` now also runs the typing round trip, so `sync.save_ack` / `notes.save` are measured (`4dc666057`). ### Gates at `be4f42562` | Gate | Command | Result | |---|---|---| | fmt | `cargo fmt --all --check` (dev-01, slot) | PASS | | clippy strict | `cargo clippy -j4 --workspace --all-targets --locked -- -D warnings` | PASS (0 errors/warnings) | | workspace tests | `cargo test -j4 --workspace --locked --no-fail-fast` (after `bun install --frozen-lockfile`) | 1,837 passed, 0 failed, 22 ignored | | crash, Linux | `cargo test -p calternal --test notes_crash_typing kill_nine_while_people_type_loses_and_doubles_nothing -- --exact` ×20, interleaved with dev `796d80cba` | PR 20/20, dev 20/20 | | crash, macOS | same ×20 on macos-01 under `/tmp/mac-bench.lock` | 20/20 | | Chromium e2e (dev-01) | `bunx playwright test e2e/{search-palette,search-corpus,editor,list-catch-up,list-search,trash-search,visibility}.spec.ts --project=chromium-1440 --project=chromium-390 --workers=1` | 77 passed, 39 skipped, 0 failed | | WebKit e2e (dev-02) | same specs, `--project=webkit-1440 --project=webkit-390` | 70 passed, 46 skipped, 0 failed | ### Perf Binaries staged on perf-01 and sha256-verified at both ends: dev `796d80cba` `bbe582a2…6dc`, candidate `be4f42562` `179dc4d1…9c9`, harness `b4989808…46d`. Session: control pair, ABAB ×5, control pair, 100k, `--search-only --gap-saves 600`. Ticket re-queued behind s4h-1100 as the orchestrator asked. perf-01 couldn't reach perf-02 over NetBird (DNS failure, then connection refused), so perf-02's lock is now taken from hd01. Results to follow in the next comment.
Author
Owner

#1011 ABAB at be4f42562 vs dev 796d80cba, 100k, perf-01: NOT READY

Session 2026-11-14 00:10–00:47 UTC (05:40–06:17 IST), one FIFO turn on perf-01 with perf-02's lock held throughout (taken from hd01). 24/24 arms exit 0 with no harness failures: control pair c0, ABAB ×5, control pair c6. calternal-perf --sizes 100k --runs 1 --cold-runs 1 --gap-saves 600 --search-only --idle-secs 0 (this now includes the typing round trip). sha256 on perf-01: dev bbe582a2…6dc, candidate 179dc4d1…9c9, harness b4989808…46d. Release builds without perf-timings, so the *_server/*_non_server splits come from took_ms only.

Comparator as in 91798/95469: per block, the mean of the two dev arms vs the mean of the two candidate arms; median over the 5 blocks. "Block spread" is the median |d1−d2|/mean within blocks; "control spread" is the larger of the two dev/dev control pairs. The verdict column is the delta against the larger of the two spreads.

Metric Stat Dev Cand Delta Block spread Control spread Worse vs spread
cold.disk_written p50 1920 MB 1930 MB +0.5% 0.1% 0.0% 4/5 OVER
cold.disk_written p95 1920 MB 1930 MB +0.5% 0.1% 0.0% 4/5 OVER
cold.first_page p50 1937 ms 1971 ms +1.8% 2.2% 9.5% 3/5 OK
cold.first_page p95 1937 ms 1971 ms +1.8% 2.2% 9.5% 3/5 OK
cold.index p50 16.67 s 16.56 s -0.7% 0.8% 3.6% 3/5 OK
cold.index p95 16.67 s 16.56 s -0.7% 0.8% 3.6% 3/5 OK
cold.mem_peak p50 293.7 MB 292.9 MB -0.3% 0.9% 3.1% 3/5 OK
cold.mem_peak p95 293.7 MB 292.9 MB -0.3% 0.9% 3.1% 3/5 OK
cold.notes_per_s p50 5999 notes/s 6040 notes/s +0.7% 0.8% 3.6% 2/5 OK
cold.notes_per_s p95 5999 notes/s 6040 notes/s +0.7% 0.8% 3.6% 2/5 OK
cold.startup p50 21.35 ms 28.85 ms +35.1% 10.0% 99.0% 4/5 OK
cold.startup p95 21.35 ms 28.85 ms +35.1% 10.0% 99.0% 4/5 OK
home.first_page p50 16.46 ms 3.951 ms -76.0% 44.9% 73.0% 0/5 OK
home.first_page p95 16.46 ms 3.951 ms -76.0% 44.9% 73.0% 0/5 OK
mem.after_first_page p50 25.79 MB 23.84 MB -7.6% 7.0% 8.0% 1/5 OK
mem.after_first_page p95 25.79 MB 23.84 MB -7.6% 7.0% 8.0% 1/5 OK
mem.after_opens p50 58.68 MB 59.75 MB +1.8% 1.2% 9.3% 5/5 OK
mem.after_opens p95 58.68 MB 59.75 MB +1.8% 1.2% 9.3% 5/5 OK
mem.after_search p50 119.2 MB 104.5 MB -12.4% 4.6% 25.0% 0/5 OK
mem.after_search p95 119.2 MB 104.5 MB -12.4% 4.6% 25.0% 0/5 OK
mem.idle p50 19.41 MB 20.23 MB +4.2% 1.4% 9.0% 3/5 OK
mem.idle p95 19.41 MB 20.23 MB +4.2% 1.4% 9.0% 3/5 OK
open.api_get p50 0.9035 ms 0.8444 ms -6.5% 9.4% 24.8% 1/5 OK
open.api_get p95 6.094 ms 4.802 ms -21.2% 39.2% 57.3% 2/5 OK
open.long_note p50 86.53 ms 96.2 ms +11.2% 6.0% 74.7% 3/5 OK
open.long_note p95 86.53 ms 96.2 ms +11.2% 6.0% 74.7% 3/5 OK
open.note p50 0.9999 ms 1.006 ms +0.6% 8.4% 71.6% 3/5 OK
open.note p95 21.13 ms 7.176 ms -66.0% 49.9% 121.6% 2/5 OK
search.catch_up p50 0.4844 s 0.004833 s -99.0% 11.8% 65.9% 0/5 OK
search.catch_up p95 0.4844 s 0.004833 s -99.0% 11.8% 65.9% 0/5 OK
search.cold_reconcile p50 27.24 s 31.82 s +16.8% 2.3% 0.7% 5/5 OVER
search.cold_reconcile p95 27.24 s 31.82 s +16.8% 2.3% 0.7% 5/5 OVER
search.first_query p50 5.273 ms 7.171 ms +36.0% 15.3% 64.2% 4/5 OK
search.first_query p95 5.273 ms 7.171 ms +36.0% 15.3% 64.2% 4/5 OK
search.first_query_client_non_server p50 0.5836 ms 0.635 ms +8.8% 11.1% 30.9% 3/5 OK
search.first_query_client_non_server p95 0.5836 ms 0.635 ms +8.8% 11.1% 30.9% 3/5 OK
search.first_query_server p50 4.701 ms 6.536 ms +39.0% 15.9% 68.2% 4/5 OK
search.first_query_server p95 4.701 ms 6.536 ms +39.0% 15.9% 68.2% 4/5 OK
search.prefix p50 2.931 ms 3.114 ms +6.2% 10.9% 28.7% 4/5 OK
search.prefix p95 4.233 ms 5.203 ms +22.9% 37.4% 70.1% 3/5 OK
search.query p50 3.229 ms 3.444 ms +6.7% 14.7% 28.9% 5/5 OK
search.query p95 7.003 ms 7.87 ms +12.4% 10.1% 52.2% 4/5 OK
search.query_client_non_server p50 0.3937 ms 0.3991 ms +1.4% 13.8% 41.8% 4/5 OK
search.query_client_non_server p95 0.6196 ms 1.591 ms +156.8% 50.8% 127.7% 5/5 OVER
search.query_server p50 2.843 ms 2.954 ms +3.9% 15.5% 29.4% 5/5 OK
search.query_server p95 6.511 ms 7.358 ms +13.0% 11.4% 53.1% 5/5 OK
search.second_query p50 3.283 ms 4.236 ms +29.0% 25.2% 72.4% 3/5 OK
search.second_query p95 3.283 ms 4.236 ms +29.0% 25.2% 72.4% 3/5 OK
search.second_query_client_non_server p50 0.4533 ms 0.8966 ms +97.8% 37.5% 164.1% 4/5 OK
search.second_query_client_non_server p95 0.4533 ms 0.8966 ms +97.8% 37.5% 164.1% 4/5 OK
search.second_query_server p50 2.832 ms 3.639 ms +28.5% 20.5% 6.7% 3/5 OVER
search.second_query_server p95 2.832 ms 3.639 ms +28.5% 20.5% 6.7% 3/5 OVER
search.third_query p50 3.404 ms 4.243 ms +24.6% 14.5% 68.8% 3/5 OK
search.third_query p95 3.404 ms 4.243 ms +24.6% 14.5% 68.8% 3/5 OK
search.third_query_client_non_server p50 0.4422 ms 0.8796 ms +98.9% 19.7% 11.9% 4/5 OVER
search.third_query_client_non_server p95 0.4422 ms 0.8796 ms +98.9% 19.7% 11.9% 4/5 OVER
search.third_query_server p50 2.935 ms 3.35 ms +14.2% 8.8% 74.9% 3/5 OK
search.third_query_server p95 2.935 ms 3.35 ms +14.2% 8.8% 74.9% 3/5 OK
search.typo p50 5.643 ms 4.108 ms -27.2% 82.5% 136.4% 0/5 OK
search.typo p95 37.96 ms 15.18 ms -60.0% 34.8% 66.5% 0/5 OK
shutdown p50 43 ms 43.09 ms +0.2% 0.6% 2.6% 4/5 OK
shutdown p95 43 ms 43.09 ms +0.2% 0.6% 2.6% 4/5 OK
startup.healthz p50 6.072 ms 5.189 ms -14.5% 11.6% 88.9% 2/5 OK
startup.healthz p95 6.072 ms 5.189 ms -14.5% 11.6% 88.9% 2/5 OK
sync.durable_write p50 25.83 ms 24.84 ms -3.8% 8.6% 18.8% 2/5 OK
sync.durable_write p95 35.57 ms 37.82 ms +6.3% 21.7% 34.2% 3/5 OK
sync.round_trip p50 0.2524 ms 0.2675 ms +6.0% 4.2% 12.2% 5/5 OK
sync.round_trip p95 0.4169 ms 0.4287 ms +2.8% 5.0% 36.1% 4/5 OK
sync.save_ack p50 3.778 ms 3.786 ms +0.2% 2.3% 4.0% 3/5 OK
sync.save_ack p95 6.38 ms 5.913 ms -7.3% 13.0% 28.7% 1/5 OK

Verdict

  • search.cold_reconcile is still +16.8% (27.2 s → 31.8 s), 5/5 blocks worse, against a 2.3% spread: this blocks. It is down from +25.8% at 326e3cab5. On compute02 the pipelined build was writer-bound and close to dev by writer activity, but on perf-01's slower shared disk it is not. The next step is a perf-01 profile of the build (writer CPU vs I/O wait, WAL size). A variant that writes hidden pages in one transaction per 64 pages, built at f3238cc06 (with the pacing I later removed), showed no win on compute02's fast disk but was never measured on perf-01. It is staged there as bin/candidate-txn-calternal, and its effect on a 6 ms-fsync disk is the open question.
  • cold.disk_written +0.5% (+10 MB, 4/5) with a 0.0–0.1% spread: technically over. It was +79 MB before the page-index change.
  • search.second_query_server +28.5% (control spread 6.7%, block spread 20.5%) and third_query_client_non_server are over on the stricter reading. first/second/third_query, search.query p50/p95 (+6.7% / +12.4%, worse in 5/5 and 4/5 blocks) and query_server are within the session's noise but consistently worse. Steady-state queries on a settled server measured equal to dev on compute02 (3.45 vs 3.60 ms server p50), so these are startup-window effects, not SQL.
  • Better: search.catch_up −99%, search.typo −27% / −60% (with corrections working now), mem.after_search −12%, cold.index −0.7% (was +4.7%), sync.save_ack +0.2% / −7.3% (flat), home.first_page, open.api_get, startup.healthz.

Not merged and not marked READY. All functional gates at this head are green (comment 95769).

## #1011 ABAB at `be4f42562` vs dev `796d80cba`, 100k, perf-01: **NOT READY** Session 2026-11-14 00:10–00:47 UTC (05:40–06:17 IST), one FIFO turn on perf-01 with perf-02's lock held throughout (taken from hd01). 24/24 arms exit 0 with no harness failures: control pair c0, ABAB ×5, control pair c6. `calternal-perf --sizes 100k --runs 1 --cold-runs 1 --gap-saves 600 --search-only --idle-secs 0` (this now includes the typing round trip). sha256 on perf-01: dev `bbe582a2…6dc`, candidate `179dc4d1…9c9`, harness `b4989808…46d`. Release builds without `perf-timings`, so the `*_server`/`*_non_server` splits come from `took_ms` only. Comparator as in 91798/95469: per block, the mean of the two dev arms vs the mean of the two candidate arms; median over the 5 blocks. "Block spread" is the median |d1−d2|/mean within blocks; "control spread" is the larger of the two dev/dev control pairs. The verdict column is the delta against the larger of the two spreads. | Metric | Stat | Dev | Cand | Delta | Block spread | Control spread | Worse | vs spread | |---|---|---:|---:|---:|---:|---:|---:|---| | `cold.disk_written` | p50 | 1920 MB | 1930 MB | +0.5% | 0.1% | 0.0% | 4/5 | **OVER** | | `cold.disk_written` | p95 | 1920 MB | 1930 MB | +0.5% | 0.1% | 0.0% | 4/5 | **OVER** | | `cold.first_page` | p50 | 1937 ms | 1971 ms | +1.8% | 2.2% | 9.5% | 3/5 | OK | | `cold.first_page` | p95 | 1937 ms | 1971 ms | +1.8% | 2.2% | 9.5% | 3/5 | OK | | `cold.index` | p50 | 16.67 s | 16.56 s | -0.7% | 0.8% | 3.6% | 3/5 | OK | | `cold.index` | p95 | 16.67 s | 16.56 s | -0.7% | 0.8% | 3.6% | 3/5 | OK | | `cold.mem_peak` | p50 | 293.7 MB | 292.9 MB | -0.3% | 0.9% | 3.1% | 3/5 | OK | | `cold.mem_peak` | p95 | 293.7 MB | 292.9 MB | -0.3% | 0.9% | 3.1% | 3/5 | OK | | `cold.notes_per_s` | p50 | 5999 notes/s | 6040 notes/s | +0.7% | 0.8% | 3.6% | 2/5 | OK | | `cold.notes_per_s` | p95 | 5999 notes/s | 6040 notes/s | +0.7% | 0.8% | 3.6% | 2/5 | OK | | `cold.startup` | p50 | 21.35 ms | 28.85 ms | +35.1% | 10.0% | 99.0% | 4/5 | OK | | `cold.startup` | p95 | 21.35 ms | 28.85 ms | +35.1% | 10.0% | 99.0% | 4/5 | OK | | `home.first_page` | p50 | 16.46 ms | 3.951 ms | -76.0% | 44.9% | 73.0% | 0/5 | OK | | `home.first_page` | p95 | 16.46 ms | 3.951 ms | -76.0% | 44.9% | 73.0% | 0/5 | OK | | `mem.after_first_page` | p50 | 25.79 MB | 23.84 MB | -7.6% | 7.0% | 8.0% | 1/5 | OK | | `mem.after_first_page` | p95 | 25.79 MB | 23.84 MB | -7.6% | 7.0% | 8.0% | 1/5 | OK | | `mem.after_opens` | p50 | 58.68 MB | 59.75 MB | +1.8% | 1.2% | 9.3% | 5/5 | OK | | `mem.after_opens` | p95 | 58.68 MB | 59.75 MB | +1.8% | 1.2% | 9.3% | 5/5 | OK | | `mem.after_search` | p50 | 119.2 MB | 104.5 MB | -12.4% | 4.6% | 25.0% | 0/5 | OK | | `mem.after_search` | p95 | 119.2 MB | 104.5 MB | -12.4% | 4.6% | 25.0% | 0/5 | OK | | `mem.idle` | p50 | 19.41 MB | 20.23 MB | +4.2% | 1.4% | 9.0% | 3/5 | OK | | `mem.idle` | p95 | 19.41 MB | 20.23 MB | +4.2% | 1.4% | 9.0% | 3/5 | OK | | `open.api_get` | p50 | 0.9035 ms | 0.8444 ms | -6.5% | 9.4% | 24.8% | 1/5 | OK | | `open.api_get` | p95 | 6.094 ms | 4.802 ms | -21.2% | 39.2% | 57.3% | 2/5 | OK | | `open.long_note` | p50 | 86.53 ms | 96.2 ms | +11.2% | 6.0% | 74.7% | 3/5 | OK | | `open.long_note` | p95 | 86.53 ms | 96.2 ms | +11.2% | 6.0% | 74.7% | 3/5 | OK | | `open.note` | p50 | 0.9999 ms | 1.006 ms | +0.6% | 8.4% | 71.6% | 3/5 | OK | | `open.note` | p95 | 21.13 ms | 7.176 ms | -66.0% | 49.9% | 121.6% | 2/5 | OK | | `search.catch_up` | p50 | 0.4844 s | 0.004833 s | -99.0% | 11.8% | 65.9% | 0/5 | OK | | `search.catch_up` | p95 | 0.4844 s | 0.004833 s | -99.0% | 11.8% | 65.9% | 0/5 | OK | | `search.cold_reconcile` | p50 | 27.24 s | 31.82 s | +16.8% | 2.3% | 0.7% | 5/5 | **OVER** | | `search.cold_reconcile` | p95 | 27.24 s | 31.82 s | +16.8% | 2.3% | 0.7% | 5/5 | **OVER** | | `search.first_query` | p50 | 5.273 ms | 7.171 ms | +36.0% | 15.3% | 64.2% | 4/5 | OK | | `search.first_query` | p95 | 5.273 ms | 7.171 ms | +36.0% | 15.3% | 64.2% | 4/5 | OK | | `search.first_query_client_non_server` | p50 | 0.5836 ms | 0.635 ms | +8.8% | 11.1% | 30.9% | 3/5 | OK | | `search.first_query_client_non_server` | p95 | 0.5836 ms | 0.635 ms | +8.8% | 11.1% | 30.9% | 3/5 | OK | | `search.first_query_server` | p50 | 4.701 ms | 6.536 ms | +39.0% | 15.9% | 68.2% | 4/5 | OK | | `search.first_query_server` | p95 | 4.701 ms | 6.536 ms | +39.0% | 15.9% | 68.2% | 4/5 | OK | | `search.prefix` | p50 | 2.931 ms | 3.114 ms | +6.2% | 10.9% | 28.7% | 4/5 | OK | | `search.prefix` | p95 | 4.233 ms | 5.203 ms | +22.9% | 37.4% | 70.1% | 3/5 | OK | | `search.query` | p50 | 3.229 ms | 3.444 ms | +6.7% | 14.7% | 28.9% | 5/5 | OK | | `search.query` | p95 | 7.003 ms | 7.87 ms | +12.4% | 10.1% | 52.2% | 4/5 | OK | | `search.query_client_non_server` | p50 | 0.3937 ms | 0.3991 ms | +1.4% | 13.8% | 41.8% | 4/5 | OK | | `search.query_client_non_server` | p95 | 0.6196 ms | 1.591 ms | +156.8% | 50.8% | 127.7% | 5/5 | **OVER** | | `search.query_server` | p50 | 2.843 ms | 2.954 ms | +3.9% | 15.5% | 29.4% | 5/5 | OK | | `search.query_server` | p95 | 6.511 ms | 7.358 ms | +13.0% | 11.4% | 53.1% | 5/5 | OK | | `search.second_query` | p50 | 3.283 ms | 4.236 ms | +29.0% | 25.2% | 72.4% | 3/5 | OK | | `search.second_query` | p95 | 3.283 ms | 4.236 ms | +29.0% | 25.2% | 72.4% | 3/5 | OK | | `search.second_query_client_non_server` | p50 | 0.4533 ms | 0.8966 ms | +97.8% | 37.5% | 164.1% | 4/5 | OK | | `search.second_query_client_non_server` | p95 | 0.4533 ms | 0.8966 ms | +97.8% | 37.5% | 164.1% | 4/5 | OK | | `search.second_query_server` | p50 | 2.832 ms | 3.639 ms | +28.5% | 20.5% | 6.7% | 3/5 | **OVER** | | `search.second_query_server` | p95 | 2.832 ms | 3.639 ms | +28.5% | 20.5% | 6.7% | 3/5 | **OVER** | | `search.third_query` | p50 | 3.404 ms | 4.243 ms | +24.6% | 14.5% | 68.8% | 3/5 | OK | | `search.third_query` | p95 | 3.404 ms | 4.243 ms | +24.6% | 14.5% | 68.8% | 3/5 | OK | | `search.third_query_client_non_server` | p50 | 0.4422 ms | 0.8796 ms | +98.9% | 19.7% | 11.9% | 4/5 | **OVER** | | `search.third_query_client_non_server` | p95 | 0.4422 ms | 0.8796 ms | +98.9% | 19.7% | 11.9% | 4/5 | **OVER** | | `search.third_query_server` | p50 | 2.935 ms | 3.35 ms | +14.2% | 8.8% | 74.9% | 3/5 | OK | | `search.third_query_server` | p95 | 2.935 ms | 3.35 ms | +14.2% | 8.8% | 74.9% | 3/5 | OK | | `search.typo` | p50 | 5.643 ms | 4.108 ms | -27.2% | 82.5% | 136.4% | 0/5 | OK | | `search.typo` | p95 | 37.96 ms | 15.18 ms | -60.0% | 34.8% | 66.5% | 0/5 | OK | | `shutdown` | p50 | 43 ms | 43.09 ms | +0.2% | 0.6% | 2.6% | 4/5 | OK | | `shutdown` | p95 | 43 ms | 43.09 ms | +0.2% | 0.6% | 2.6% | 4/5 | OK | | `startup.healthz` | p50 | 6.072 ms | 5.189 ms | -14.5% | 11.6% | 88.9% | 2/5 | OK | | `startup.healthz` | p95 | 6.072 ms | 5.189 ms | -14.5% | 11.6% | 88.9% | 2/5 | OK | | `sync.durable_write` | p50 | 25.83 ms | 24.84 ms | -3.8% | 8.6% | 18.8% | 2/5 | OK | | `sync.durable_write` | p95 | 35.57 ms | 37.82 ms | +6.3% | 21.7% | 34.2% | 3/5 | OK | | `sync.round_trip` | p50 | 0.2524 ms | 0.2675 ms | +6.0% | 4.2% | 12.2% | 5/5 | OK | | `sync.round_trip` | p95 | 0.4169 ms | 0.4287 ms | +2.8% | 5.0% | 36.1% | 4/5 | OK | | `sync.save_ack` | p50 | 3.778 ms | 3.786 ms | +0.2% | 2.3% | 4.0% | 3/5 | OK | | `sync.save_ack` | p95 | 6.38 ms | 5.913 ms | -7.3% | 13.0% | 28.7% | 1/5 | OK | ### Verdict - **`search.cold_reconcile` is still +16.8% (27.2 s → 31.8 s), 5/5 blocks worse, against a 2.3% spread: this blocks.** It is down from +25.8% at `326e3cab5`. On compute02 the pipelined build was writer-bound and close to dev by writer activity, but on perf-01's slower shared disk it is not. The next step is a perf-01 profile of the build (writer CPU vs I/O wait, WAL size). A variant that writes hidden pages in one transaction per 64 pages, built at `f3238cc06` (with the pacing I later removed), showed no win on compute02's fast disk but was never measured on perf-01. It is staged there as `bin/candidate-txn-calternal`, and its effect on a 6 ms-fsync disk is the open question. - `cold.disk_written` +0.5% (+10 MB, 4/5) with a 0.0–0.1% spread: technically over. It was +79 MB before the page-index change. - `search.second_query_server` +28.5% (control spread 6.7%, block spread 20.5%) and `third_query_client_non_server` are over on the stricter reading. `first/second/third_query`, `search.query` p50/p95 (+6.7% / +12.4%, worse in 5/5 and 4/5 blocks) and `query_server` are within the session's noise but consistently worse. Steady-state queries on a settled server measured equal to dev on compute02 (3.45 vs 3.60 ms server p50), so these are startup-window effects, not SQL. - Better: `search.catch_up` −99%, `search.typo` −27% / −60% (with corrections working now), `mem.after_search` −12%, `cold.index` −0.7% (was +4.7%), `sync.save_ack` +0.2% / −7.3% (flat), `home.first_page`, `open.api_get`, `startup.healthz`. Not merged and not marked READY. All functional gates at this head are green (comment 95769).
Author
Owner

#1011 resume, 15 Nov: cold build profiled on perf-01, cause found (interim, NOT READY)

Merge. origin/dev ee50429e7 merged into the PR branch (f06a1c4db). Conflicts: dev moved the Home list-sync methods into meta/sync.rs, so the branch's live_meta source-version fence moved with them. Dev's Trash-as-executor change installs history for live images only, so the save receipt's source_version is now taken by live position (Trash keeps dev's notes.deleted receipt), and executor_meta checks versions against the live count (8c6807e18; six Tasks delete tests failed without it). 475751824 fills dev's new plan fields in one search test. Gates at 8c6807e18 on dev-01: cargo fmt --all --check PASS, cargo clippy -j4 --workspace --all-targets --locked -- -D warnings PASS, cargo test -j4 --workspace --locked --no-fail-fast PASS.

Profile (perf-01, my own 100k fixture, one FIFO turn with perf-02 held from hd01, 12:36–12:45 IST). Same harness command as the ABAB (--sizes 100k --runs 1 --cold-runs 1 --gap-saves 600 --search-only --idle-secs 0). A /proc sampler took per-thread state, current syscall and schedstat (on-CPU vs run-queue wait) every 20 ms, plus PSI and sda stats. Order: dev, cand, txn, txn, cand, dev. Diagnostic only: not a gate.

In the cold-reconcile window dev (2 arms) cand f06a1c4db (2) cand + 64-page txn (2)
search.cold_reconcile 26.9 / 26.7 s 26.5 / 27.0 s 23.6 / 23.4 s
search-writer on CPU 20.0 / 19.8 s 22.5 s 20.8 s
writer runnable / futex wait 79% / 20% 89% / 10% 95% / 3%
writer in fsync/fdatasync ~0% ~0% ~0%
run-queue wait (all threads) <0.1 s 0.2 s 0.1 s
bytes written by the server 1.45 GB 2.94 GB 1.43 GB
server lifetime (build + tail) 33.1 s 41.6 / 43.7 s 30.7 / 28.7 s
  • The build is writer-CPU-bound on perf-01 in both binaries. It isn't waiting on the disk, on fsync or on CPU (4 cores, <0.2 s of run-queue wait). So the "6 ms fsync disk" theory is out.
  • The cost is WAL write amplification. With one commit per provider page (~390 at 100k), every commit rewrites the same FTS segment and b-tree pages into the WAL. That's 2× dev's bytes, paid in writer CPU, and then ~9 s of checkpointing a ~3 GB WAL after search reports ready, which overlaps the next phases.
  • One transaction per 64 hidden pages fixes it: bytes back to dev's level, build −12% vs dev, and no post-ready tail. compute02's fast disk hid this. I'm bringing it back (d035fd919, reapplying f3238cc06 on the current head), now with unit tests for the page budget, rollback and the failed-commit path.
  • Warm-run queries: in the warm-run process the candidate uses less CPU than dev, with no run-queue wait and no extra disk. So first_query (5.4–5.8 → 7.9–9.8 ms in every candidate arm) and second_query_server aren't contention. My lead is the typo-vocabulary warm-up (eb463d5aa). Catch-up now ends in ~5 ms, so the warm-up starts right away, takes the pooled warm reader and scans the whole vocab table while the first queries run. In dev it's lazy. A second diagnostic turn (queued) compares txn against two variants: no warm-up, and warm-up on its own private connection.

ADR 0070. Dev's #1156 made the size check a train blocker. This PR had search/index.rs 699, indexer/sync.rs 808 and write.rs 778 code lines (limit 500), read.rs 891 (ceiling 845) and notes/meta.rs 1304 (ceiling 1289), and it grew write_executor/home.rs by 30. Split by job with pure moves (04026fa14 plus fmt/visibility follow-ups), now on wip/mail1011-final-1115. Every PR-owned file is under its limit; the remaining check-size-budgets/check-file-docs/check-ui-primitives messages are the same ones dev ee50429e7 prints. fmt, strict workspace clippy, and cargo test -p calternal-search -p calternal-notes -p calternal-tasks pass there.

Next: decide the vocab fix from the diagnostic turn, then the #1130 comparator turns (dev, dev2, inert sized to the candidate's growth, cand; mirrored; second turn to confirm).

## #1011 resume, 15 Nov: cold build profiled on perf-01, cause found (interim, NOT READY) **Merge.** `origin/dev` `ee50429e7` merged into the PR branch (`f06a1c4db`). Conflicts: dev moved the Home list-sync methods into `meta/sync.rs`, so the branch's `live_meta` source-version fence moved with them. Dev's Trash-as-executor change installs history for live images only, so the save receipt's `source_version` is now taken by live position (Trash keeps dev's `notes.deleted` receipt), and `executor_meta` checks versions against the live count (`8c6807e18`; six Tasks delete tests failed without it). `475751824` fills dev's new plan fields in one search test. Gates at `8c6807e18` on dev-01: `cargo fmt --all --check` PASS, `cargo clippy -j4 --workspace --all-targets --locked -- -D warnings` PASS, `cargo test -j4 --workspace --locked --no-fail-fast` PASS. **Profile (perf-01, my own 100k fixture, one FIFO turn with perf-02 held from hd01, 12:36–12:45 IST).** Same harness command as the ABAB (`--sizes 100k --runs 1 --cold-runs 1 --gap-saves 600 --search-only --idle-secs 0`). A /proc sampler took per-thread state, current syscall and schedstat (on-CPU vs run-queue wait) every 20 ms, plus PSI and sda stats. Order: dev, cand, txn, txn, cand, dev. Diagnostic only: not a gate. | In the cold-reconcile window | dev (2 arms) | cand `f06a1c4db` (2) | cand + 64-page txn (2) | |---|---:|---:|---:| | `search.cold_reconcile` | 26.9 / 26.7 s | 26.5 / 27.0 s | **23.6 / 23.4 s** | | `search-writer` on CPU | 20.0 / 19.8 s | 22.5 s | 20.8 s | | writer runnable / futex wait | 79% / 20% | 89% / 10% | 95% / 3% | | writer in fsync/fdatasync | ~0% | ~0% | ~0% | | run-queue wait (all threads) | <0.1 s | 0.2 s | 0.1 s | | bytes written by the server | 1.45 GB | **2.94 GB** | 1.43 GB | | server lifetime (build + tail) | 33.1 s | 41.6 / 43.7 s | 30.7 / 28.7 s | - **The build is writer-CPU-bound on perf-01 in both binaries.** It isn't waiting on the disk, on fsync or on CPU (4 cores, <0.2 s of run-queue wait). So the "6 ms fsync disk" theory is out. - **The cost is WAL write amplification.** With one commit per provider page (~390 at 100k), every commit rewrites the same FTS segment and b-tree pages into the WAL. That's 2× dev's bytes, paid in writer CPU, and then ~9 s of checkpointing a ~3 GB WAL after search reports ready, which overlaps the next phases. - **One transaction per 64 hidden pages fixes it**: bytes back to dev's level, build **−12% vs dev**, and no post-ready tail. compute02's fast disk hid this. I'm bringing it back (`d035fd919`, reapplying `f3238cc06` on the current head), now with unit tests for the page budget, rollback and the failed-commit path. - **Warm-run queries:** in the warm-run process the candidate uses *less* CPU than dev, with no run-queue wait and no extra disk. So `first_query` (5.4–5.8 → 7.9–9.8 ms in every candidate arm) and `second_query_server` aren't contention. My lead is the typo-vocabulary warm-up (`eb463d5aa`). Catch-up now ends in ~5 ms, so the warm-up starts right away, takes the pooled warm reader and scans the whole vocab table while the first queries run. In dev it's lazy. A second diagnostic turn (queued) compares txn against two variants: no warm-up, and warm-up on its own private connection. **ADR 0070.** Dev's #1156 made the size check a train blocker. This PR had `search/index.rs` 699, `indexer/sync.rs` 808 and `write.rs` 778 code lines (limit 500), `read.rs` 891 (ceiling 845) and `notes/meta.rs` 1304 (ceiling 1289), and it grew `write_executor/home.rs` by 30. Split by job with pure moves (`04026fa14` plus fmt/visibility follow-ups), now on `wip/mail1011-final-1115`. Every PR-owned file is under its limit; the remaining `check-size-budgets`/`check-file-docs`/`check-ui-primitives` messages are the same ones dev `ee50429e7` prints. fmt, strict workspace clippy, and `cargo test -p calternal-search -p calternal-notes -p calternal-tasks` pass there. Next: decide the vocab fix from the diagnostic turn, then the #1130 comparator turns (dev, dev2, inert sized to the candidate's growth, cand; mirrored; second turn to confirm).
Author
Owner

#1011 #1130 comparator turn 1 at ac5669771: cold reconcile −12%, steady queries flagged → fixed in a36df6760 (NOT READY)

Turn 1 (perf-01, FIFO turn 15:30–16:38 IST, perf-02 held from hd01 the whole time). perf/vm/paired-turn.sh --sizes 100k --runs 1 --cold-runs 1 --deadline-min 80 --seed 1115 --order mirrored --warmup --handshake -- --gap-saves 600 --search-only --cold-timeout 900, with arms dev ee50429e7 (e1d5542f…), dev2 (byte copy), inert (ee50429e7 + perf/inert-patch.py --seed 1 --functions 1360, +303 KB against the candidate's +321 KB, c6626800…), and cand ac5669771 (c0a8602b…). Harness 646becde…. 10 rounds, 0 harness failures. python3 perf/compare.py layout.json --hot search.,cold.,sync. --layout inert: null block dev2 vs dev passed (no cell flagged), so the turn is valid.

Hot cell (cand vs dev) Ratio Upper 95% MDE adj. p Result
search.cold_reconcile 0.881 0.903 3.7% 1.000 ok (−12%)
cold.index 1.019 1.036 2.5% 0.47 ok
cold.disk_written 1.0057 1.0060 0.0% 0.001 FLAGGED (also vs inert)
search.query p50 / p95 1.088 / 1.119 1.136 / 1.185 6.6 / 8.8% 0.049 / 0.046 FLAGGED
search.query_server p50 1.076 1.112 5.1% 0.023 FLAGGED (also vs inert)
search.prefix p95 1.338 1.542 23.3% 0.036 FLAGGED (also vs inert)
search.first_query 1.376 1.747 42.6% 0.28 unresolved (MDE > 10%)
search.second_query_server 1.206 1.476 34.9% 0.61 unresolved
search.typo p95 0.541 0.618 21.6% 1.000 ok (better)
sync.save_ack p50 / p95 0.984 / 0.878 1.063 / 1.060 0.98 / 1.00 ok / unresolved

All smoke cells ok. Comparator verdict: REGRESSION FLAGGED on 3 cells (cold.disk_written, search.prefix p95, search.query_server p50).

Cause of the steady-query flags (dev-01, structure only, no timing claims). I built the 100k index once with each binary and compared the files. Schema and rows are the same (the _next tables have the same columns and indexes as dev's). The same search-shaped SQL (FTS newest + titles, 8 queries, 40 interleaved rounds, ×3) ran 4.4–5.4% slower on the candidate's file. After VACUUM INTO it was still slower, so it isn't page layout. After FTS5 optimize on both it was equal (2.77 vs 2.77–2.83 ms). So the gap is FTS segment shape from the batched commits. Merging only the candidate's small titles and tri tables made it 5–7% faster than dev (4.33–4.46 vs 4.62–4.70 ms). That costs 0.17 s + 0.2 s at 100k; a full-text optimize would cost 6.4 s, so I left that one alone. a36df6760 merges titles/tri of a hidden generation inside the publish transaction, before the manifest switch.

cold.disk_written +0.57% (+~10 MB of 1.92 GB): needs a decision, not a fix tonight. It's deterministic, so any delta flags. It comes from the branch's source_versions snapshot table and its (updated, id) index in the notes list store. That index keeps each keyset search page O(page) instead of a sort over the whole list, and it's built once at the end of a fresh fill (FRESH_DROPS). cold.index time and cold.mem_peak are flat. Removing it means redesigning the pinned snapshot, so I'm leaving that call to kayg/the orchestrator.

Next: turn 2 (queued; candidate swapped to a36df6760 = 09a246c8… before it started, so it's a fresh measurement of the fixed head). If it flags or comes back inconclusive, a confirming turn 3 with --only. 243b21238 is the PR head (rustfmt-only on top of a36df6760).

Other: cargo test --workspace at ac5669771 had one failure in calternal-auth (a_cold_valid_password_gets_through_a_concurrent_flood, 429 vs 200). It isn't touched by the PR, passed 10/10 alone on the PR head and on dev, and was green at 8c6807e18. Filed as #1157 (flaky rule: not blocking).

## #1011 #1130 comparator turn 1 at `ac5669771`: cold reconcile −12%, steady queries flagged → fixed in `a36df6760` (NOT READY) **Turn 1** (perf-01, FIFO turn 15:30–16:38 IST, perf-02 held from hd01 the whole time). `perf/vm/paired-turn.sh --sizes 100k --runs 1 --cold-runs 1 --deadline-min 80 --seed 1115 --order mirrored --warmup --handshake -- --gap-saves 600 --search-only --cold-timeout 900`, with arms dev `ee50429e7` (`e1d5542f…`), dev2 (byte copy), inert (`ee50429e7` + `perf/inert-patch.py --seed 1 --functions 1360`, +303 KB against the candidate's +321 KB, `c6626800…`), and cand `ac5669771` (`c0a8602b…`). Harness `646becde…`. 10 rounds, 0 harness failures. `python3 perf/compare.py layout.json --hot search.,cold.,sync. --layout inert`: null block dev2 vs dev passed (no cell flagged), so the turn is valid. | Hot cell (cand vs dev) | Ratio | Upper 95% | MDE | adj. p | Result | |---|---:|---:|---:|---:|---| | `search.cold_reconcile` | **0.881** | 0.903 | 3.7% | 1.000 | ok (−12%) | | `cold.index` | 1.019 | 1.036 | 2.5% | 0.47 | ok | | `cold.disk_written` | 1.0057 | 1.0060 | 0.0% | 0.001 | **FLAGGED** (also vs inert) | | `search.query` p50 / p95 | 1.088 / 1.119 | 1.136 / 1.185 | 6.6 / 8.8% | 0.049 / 0.046 | **FLAGGED** | | `search.query_server` p50 | 1.076 | 1.112 | 5.1% | 0.023 | **FLAGGED** (also vs inert) | | `search.prefix` p95 | 1.338 | 1.542 | 23.3% | 0.036 | **FLAGGED** (also vs inert) | | `search.first_query` | 1.376 | 1.747 | 42.6% | 0.28 | unresolved (MDE > 10%) | | `search.second_query_server` | 1.206 | 1.476 | 34.9% | 0.61 | unresolved | | `search.typo` p95 | 0.541 | 0.618 | 21.6% | 1.000 | ok (better) | | `sync.save_ack` p50 / p95 | 0.984 / 0.878 | 1.063 / 1.060 | | 0.98 / 1.00 | ok / unresolved | All smoke cells ok. Comparator verdict: REGRESSION FLAGGED on 3 cells (`cold.disk_written`, `search.prefix` p95, `search.query_server` p50). **Cause of the steady-query flags (dev-01, structure only, no timing claims).** I built the 100k index once with each binary and compared the files. Schema and rows are the same (the `_next` tables have the same columns and indexes as dev's). The same search-shaped SQL (FTS newest + titles, 8 queries, 40 interleaved rounds, ×3) ran **4.4–5.4% slower on the candidate's file**. After `VACUUM INTO` it was still slower, so it isn't page layout. After FTS5 `optimize` on both it was **equal** (2.77 vs 2.77–2.83 ms). So the gap is FTS segment shape from the batched commits. Merging only the candidate's small `titles` and `tri` tables made it **5–7% faster than dev** (4.33–4.46 vs 4.62–4.70 ms). That costs 0.17 s + 0.2 s at 100k; a full-text `optimize` would cost 6.4 s, so I left that one alone. `a36df6760` merges `titles`/`tri` of a hidden generation inside the publish transaction, before the manifest switch. **`cold.disk_written` +0.57% (+~10 MB of 1.92 GB): needs a decision, not a fix tonight.** It's deterministic, so any delta flags. It comes from the branch's `source_versions` snapshot table and its `(updated, id)` index in the notes list store. That index keeps each keyset search page O(page) instead of a sort over the whole list, and it's built once at the end of a fresh fill (`FRESH_DROPS`). `cold.index` time and `cold.mem_peak` are flat. Removing it means redesigning the pinned snapshot, so I'm leaving that call to kayg/the orchestrator. **Next:** turn 2 (queued; candidate swapped to `a36df6760` = `09a246c8…` before it started, so it's a fresh measurement of the fixed head). If it flags or comes back inconclusive, a confirming turn 3 with `--only`. `243b21238` is the PR head (rustfmt-only on top of `a36df6760`). Other: `cargo test --workspace` at `ac5669771` had one failure in `calternal-auth` (`a_cold_valid_password_gets_through_a_concurrent_flood`, 429 vs 200). It isn't touched by the PR, passed 10/10 alone on the PR head and on dev, and was green at `8c6807e18`. Filed as #1157 (flaky rule: not blocking).
Author
Owner

#1011 comparator turn 2 at 72c613833 (dev 42c219afd merged): queries fixed, cold.index flagged → profiling (NOT READY)

Merge. origin/dev 42c219afd merged into the branch as 72c613833, with no conflicts. Dev's changes since ee50429e7 are web, docs and harness only, so the rebuilt release binaries are byte-identical to the last ones: dev e1d5542f…, cand 09a246c8… (= a36df6760/44bc6230a).

Gates at 72c613833

  • dev-01: cargo fmt --all --check PASS; cargo clippy -j4 --workspace --all-targets --locked -- -D warnings PASS.
  • dev-01: cargo test -j4 --workspace --locked --no-fail-fast had 2 failures, both flaky on dev too (filed #1166):
    • calternal-notes save_outside_retry: 5/30 on head, 3/29 on dev, interleaved;
    • calternal-store a_once_commit_does_not_update_flush_activity: 1/10 on head, 0/10 on dev; the store code is identical on both.
  • Playwright, e2e/{search-palette,search-corpus,search-preview-cheap,editor,list-catch-up,list-search,trash-search,visibility,lazy-offline}.spec.ts --workers=1. There are no mail specs in apps/web/e2e.
    • dev-01 chromium-1440 + chromium-390: 81 passed, 41 skipped, 0 failed;
    • dev-02 webkit-1440 + webkit-390: 72 passed, 50 skipped, 0 failed.

Turn 2 (perf-01, FIFO ticket, measured 21:41–22:54 CET = 02:11–03:24 IST; perf-02 held by my own unit m1011-hold-tA only during the turn).

  • Command: paired-turn.sh --sizes 100k --runs 1 --cold-runs 1 --deadline-min 80 --seed 1116 --order mirrored --warmup --handshake -- --gap-saves 600 --search-only --cold-timeout 900 (same as turn 1, new seed).
  • Arms:
    • dev e1d5542f…;
    • dev2 (byte copy);
    • inert: 42c219afd + inert-patch.py --seed 1 --functions 1360 = 514a0c44…, +316,776 B against the candidate's +322,016 B;
    • cand 09a246c8….
  • Harness 646becde… (the same binary as turn 1).
  • 8 rounds (256 exact flips), 0 harness failures. The null block passed.

compare.py tA/layout.json --hot search.,cold.,sync. (strict, without --layout):

Hot cell (cand vs dev) Ratio Upper 95% MDE adj. p Result
cold.disk_written 1.0077 1.0097 0.3% 0.012 FLAGGED (accepted: the (updated, id) index, kayg 16 Nov)
cold.index (and cold.notes_per_s) 1.137 1.198 8.0% 0.035 FLAGGED
search.cold_reconcile 1.047 1.146 14.3% 0.98 unresolved (turn 1: 0.881)
search.query p50 / p95 0.889 / 0.907 0.978 / 1.066 15.0 / 26.9% 1.0 ok (turn 1: 1.088 / 1.119 flagged)
search.query_server p50 0.913 1.006 15.5% 1.0 unresolved (turn 1: 1.076 flagged)
search.prefix p95 0.798 0.929 25.3% 1.0 ok (turn 1: 1.338 flagged)
search.first_query 0.661 0.827 39.2% 1.0 unresolved
search.second_query_server 1.136 1.282 19.6% 0.57 unresolved
sync.save_ack p50 / p95 0.992 / 1.111 1.033 / 1.316 1.0 / 0.97 ok / ok
  • All smoke cells are ok.
  • With --layout inert, the three cold cells go to "layout, not code" (cand vs inert: cold.index 1.170, U 1.294, p 0.16), and the verdict is INCONCLUSIVE (20 hot cells above the 10% MDE).
  • Under the strict rule this turn flags cold.index.

Reading it

  • The titles/tri merge in a36df6760 cleared all three steady-query flags from turn 1.
  • This turn was much noisier than turn 1. The rounds split into two regimes: rounds 1–5 had dev search.cold_reconcile at 47–51 s, rounds 6–8 at 35–40 s, and turn 1 at 28–29 s. So the backup01 host was under outside load (perf-02 was held by me the whole time).
  • Under that load, cand's cold-reconcile lead is gone. Cand's cold.index (the notes list scan of a fresh Home, not search) was slower than dev in 8/8 rounds, by 2–5 s on 17–23 s. In turn 1 it was within ±1 s.

Next

  • A diagnostic turn is queued behind daily-1116c-r and tf1. It runs the same harness on dev / cand / cand without a36df6760 (c0a8602b…), mirrored, with the /proc thread sampler and notes meta.indexes timings in the server log. It separates the end-of-fill index build (source_updated_id) from the publish-time title merge and from host load.
  • Then a fix if one is needed, a new turn 3, and a confirm turn.
## #1011 comparator turn 2 at `72c613833` (dev `42c219afd` merged): queries fixed, `cold.index` flagged → profiling (NOT READY) **Merge.** `origin/dev` `42c219afd` merged into the branch as `72c613833`, with no conflicts. Dev's changes since `ee50429e7` are web, docs and harness only, so the rebuilt release binaries are **byte-identical** to the last ones: dev `e1d5542f…`, cand `09a246c8…` (= `a36df6760`/`44bc6230a`). **Gates at `72c613833`** - dev-01: `cargo fmt --all --check` PASS; `cargo clippy -j4 --workspace --all-targets --locked -- -D warnings` PASS. - dev-01: `cargo test -j4 --workspace --locked --no-fail-fast` had 2 failures, both flaky on dev too (filed **#1166**): - `calternal-notes` `save_outside_retry`: 5/30 on head, 3/29 on dev, interleaved; - `calternal-store` `a_once_commit_does_not_update_flush_activity`: 1/10 on head, 0/10 on dev; the store code is identical on both. - Playwright, `e2e/{search-palette,search-corpus,search-preview-cheap,editor,list-catch-up,list-search,trash-search,visibility,lazy-offline}.spec.ts --workers=1`. There are no mail specs in `apps/web/e2e`. - dev-01 chromium-1440 + chromium-390: **81 passed, 41 skipped, 0 failed**; - dev-02 webkit-1440 + webkit-390: **72 passed, 50 skipped, 0 failed**. **Turn 2** (perf-01, FIFO ticket, measured 21:41–22:54 CET = 02:11–03:24 IST; perf-02 held by my own unit `m1011-hold-tA` only during the turn). - Command: `paired-turn.sh --sizes 100k --runs 1 --cold-runs 1 --deadline-min 80 --seed 1116 --order mirrored --warmup --handshake -- --gap-saves 600 --search-only --cold-timeout 900` (same as turn 1, new seed). - Arms: - dev `e1d5542f…`; - dev2 (byte copy); - inert: `42c219afd` + `inert-patch.py --seed 1 --functions 1360` = `514a0c44…`, +316,776 B against the candidate's +322,016 B; - cand `09a246c8…`. - Harness `646becde…` (the same binary as turn 1). - 8 rounds (256 exact flips), 0 harness failures. The null block passed. `compare.py tA/layout.json --hot search.,cold.,sync.` (strict, without `--layout`): | Hot cell (cand vs dev) | Ratio | Upper 95% | MDE | adj. p | Result | |---|---:|---:|---:|---:|---| | `cold.disk_written` | 1.0077 | 1.0097 | 0.3% | 0.012 | FLAGGED (accepted: the `(updated, id)` index, kayg 16 Nov) | | **`cold.index`** (and `cold.notes_per_s`) | **1.137** | 1.198 | 8.0% | **0.035** | **FLAGGED** | | `search.cold_reconcile` | 1.047 | 1.146 | 14.3% | 0.98 | unresolved (turn 1: 0.881) | | `search.query` p50 / p95 | 0.889 / 0.907 | 0.978 / 1.066 | 15.0 / 26.9% | 1.0 | ok (turn 1: 1.088 / 1.119 flagged) | | `search.query_server` p50 | 0.913 | 1.006 | 15.5% | 1.0 | unresolved (turn 1: 1.076 flagged) | | `search.prefix` p95 | 0.798 | 0.929 | 25.3% | 1.0 | ok (turn 1: 1.338 flagged) | | `search.first_query` | 0.661 | 0.827 | 39.2% | 1.0 | unresolved | | `search.second_query_server` | 1.136 | 1.282 | 19.6% | 0.57 | unresolved | | `sync.save_ack` p50 / p95 | 0.992 / 1.111 | 1.033 / 1.316 | | 1.0 / 0.97 | ok / ok | - All smoke cells are ok. - With `--layout inert`, the three cold cells go to "layout, not code" (cand vs inert: `cold.index` 1.170, U 1.294, p 0.16), and the verdict is INCONCLUSIVE (20 hot cells above the 10% MDE). - **Under the strict rule this turn flags `cold.index`.** **Reading it** - The `titles`/`tri` merge in `a36df6760` cleared all three steady-query flags from turn 1. - This turn was much noisier than turn 1. The rounds split into two regimes: rounds 1–5 had dev `search.cold_reconcile` at 47–51 s, rounds 6–8 at 35–40 s, and turn 1 at 28–29 s. So the backup01 host was under outside load (perf-02 was held by me the whole time). - Under that load, cand's cold-reconcile lead is gone. Cand's `cold.index` (the notes list scan of a fresh Home, not search) was slower than dev in 8/8 rounds, by 2–5 s on 17–23 s. In turn 1 it was within ±1 s. **Next** - A diagnostic turn is queued behind daily-1116c-r and tf1. It runs the same harness on dev / cand / cand without `a36df6760` (`c0a8602b…`), mirrored, with the /proc thread sampler and notes `meta.indexes` timings in the server log. It separates the end-of-fill index build (`source_updated_id`) from the publish-time title merge and from host load. - Then a fix if one is needed, a new turn 3, and a confirm turn.
Author
Owner

#1011 diagnostic turn (perf-01, 00:08–00:41 CET = 04:38–05:11 IST): cold.index isn't the candidate's code; single-root wake-ups flat

This was one FIFO ticket with perf-02 held by my own unit (m1011-hold-prof) from want to done. It is a diagnostic, not a gate.

  • Part 1, same harness command as the turns: --sizes 100k --runs 1 --cold-runs 1 --gap-saves 600 --search-only --idle-secs 0, with RUST_LOG=warn,calternal_notes=debug, a per-arm wrapper keeping every server's log, and the /proc thread sampler.
    • Order: dev, cand 09a246c8…, ac56 (c0a8602b… = cand without a36df6760), ac56, cand, dev.
Arm cold.index s notes meta.indexes s cold process CPU s search.cold_reconcile s reconcile process CPU s (writer)
dev 1 15.9 1.66 21.7 31.6 29.7 (22.9)
cand 1 22.9 2.06 22.8 34.3 32.1 (23.4)
ac56 1 16.5 1.94 23.4 34.3 32.6 (23.8)
ac56 2 16.4 2.02 22.5 35.6 32.2 (23.6)
cand 2 16.6 1.93 22.7 35.5 32.8 (23.9)
dev 2 16.9 1.96 — 32.4 30.0 (23.1)

cold.index

  • The search writer does no work in the cold process (0.0 s), so a36df6760 can't touch it, and cand and ac56 spend the same CPU there.
  • cand 1's 22.9 s was a disk stall. It used the same CPU as the others, but its window had psi_io_full 4.9 s against 1.2–1.7 s for the others, and 9.5 s in flushes against ~3.3 s.
  • Without the stall, cand is 16.6 s against dev's 15.9/16.9.
  • The end-of-fill index build (source_updated_id) costs about +0.0–0.4 s here. dev-01's offline SQL gives CREATE INDEX (updated, id) = 0.40 s on the 100k meta.db (450 MB of source text).
  • So I expect turn 2's 8/8 cold rounds came from host disk load, which was heavy all night. The confirm turn decides this, not me.

search.cold_reconcile reversed against turn 1

  • Tonight cand and ac56 are both +8–10% against dev. In turn 1 ac56 was −12%.
  • In the reconcile process cand does ~3–4× more read IOs than dev (60–78k against 18–23k) and fewer bytes (0.44–0.53 GB against 1.2 GB). Its tokio threads use +2 s CPU (8.3–8.5 s against 6.4–6.6 s). The writer is equal within 1 s.
  • The paged walk reads source_versions in (updated, id) order, which is random against the rowid order of the 450 MB table. Dev's single list() reads it sequentially.
  • With a quiet disk (turn 1) the batched writes won; under tonight's disk contention the random reads cost more.
  • Turn 2 left this cell unresolved (1.047, U 1.146). If the confirm turn flags it, the fix is to read a page's sources in table order (sort the page's ids by rowid before docs()), or a sequential first fill. That is a design change, so I'll write it up rather than rush it in at night.

Part 2: prod-like single root (no --state-dir: app data inside the Home, like prod's /data). calternal-perf --sizes 100k --runs 1 --cold-runs 1 --idle-secs 120, full scenario set, order dev, cand, cand, dev:

Metric dev 1 cand 1 cand 2 dev 2
idle.cpu_ticks (120 s) 69 67 69 70
idle.cpu_pct 0.575 0.558 0.575 0.583
idle.wakeups_per_s 5.34 5.36 5.29 5.33
idle.threads 13 13 13 13
load.typing_cpu_pct 1.62 1.30 1.35 1.65
load.typing_wakeups_per_s 70.0 66.8 67.1 71.7
sync.save_ack p50 ms 5.56 4.65 6.39 5.14
mem.idle MB 19.5 21.4 21.6 19.0
cold.index s 18.0 16.5 16.6 16.3
  • Idle CPU, idle wake-ups, threads and typing wake-ups are flat or lower in the prod layout. There's no idle loop or watcher churn from the save-log token or the paged reconcile.
  • mem.idle is +2.0–2.6 MB (~+12%) in both cand runs. The comparator's split-state turn 2 had it at 1.002 (U 1.034), so it doesn't show in the gate layout. Two runs per arm isn't a test; I'm flagging it for the morning.

Turn 3 (confirm, seed 1117, same command and binaries) started 00:41 CET.

## #1011 diagnostic turn (perf-01, 00:08–00:41 CET = 04:38–05:11 IST): `cold.index` isn't the candidate's code; single-root wake-ups flat This was one FIFO ticket with perf-02 held by my own unit (`m1011-hold-prof`) from want to done. It is a diagnostic, not a gate. - Part 1, same harness command as the turns: `--sizes 100k --runs 1 --cold-runs 1 --gap-saves 600 --search-only --idle-secs 0`, with `RUST_LOG=warn,calternal_notes=debug`, a per-arm wrapper keeping every server's log, and the /proc thread sampler. - Order: dev, cand `09a246c8…`, ac56 (`c0a8602b…` = cand without `a36df6760`), ac56, cand, dev. | Arm | `cold.index` s | notes `meta.indexes` s | cold process CPU s | `search.cold_reconcile` s | reconcile process CPU s (writer) | |---|---:|---:|---:|---:|---:| | dev 1 | 15.9 | 1.66 | 21.7 | 31.6 | 29.7 (22.9) | | cand 1 | **22.9** | 2.06 | 22.8 | 34.3 | 32.1 (23.4) | | ac56 1 | 16.5 | 1.94 | 23.4 | 34.3 | 32.6 (23.8) | | ac56 2 | 16.4 | 2.02 | 22.5 | 35.6 | 32.2 (23.6) | | cand 2 | 16.6 | 1.93 | 22.7 | 35.5 | 32.8 (23.9) | | dev 2 | 16.9 | 1.96 | — | 32.4 | 30.0 (23.1) | **`cold.index`** - The search writer does no work in the cold process (0.0 s), so `a36df6760` can't touch it, and cand and ac56 spend the same CPU there. - cand 1's 22.9 s was a disk stall. It used the same CPU as the others, but its window had `psi_io_full` 4.9 s against 1.2–1.7 s for the others, and 9.5 s in flushes against ~3.3 s. - Without the stall, cand is 16.6 s against dev's 15.9/16.9. - The end-of-fill index build (`source_updated_id`) costs about +0.0–0.4 s here. dev-01's offline SQL gives `CREATE INDEX (updated, id)` = 0.40 s on the 100k `meta.db` (450 MB of `source` text). - So I expect turn 2's 8/8 cold rounds came from host disk load, which was heavy all night. The confirm turn decides this, not me. **`search.cold_reconcile` reversed against turn 1** - Tonight cand and ac56 are both +8–10% against dev. In turn 1 ac56 was −12%. - In the reconcile process cand does ~3–4× more read IOs than dev (60–78k against 18–23k) and fewer bytes (0.44–0.53 GB against 1.2 GB). Its tokio threads use +2 s CPU (8.3–8.5 s against 6.4–6.6 s). The writer is equal within 1 s. - The paged walk reads `source_versions` in `(updated, id)` order, which is random against the rowid order of the 450 MB table. Dev's single `list()` reads it sequentially. - With a quiet disk (turn 1) the batched writes won; under tonight's disk contention the random reads cost more. - Turn 2 left this cell unresolved (1.047, U 1.146). If the confirm turn flags it, the fix is to read a page's sources in table order (sort the page's ids by rowid before `docs()`), or a sequential first fill. That is a design change, so I'll write it up rather than rush it in at night. **Part 2: prod-like single root** (no `--state-dir`: app data inside the Home, like prod's `/data`). `calternal-perf --sizes 100k --runs 1 --cold-runs 1 --idle-secs 120`, full scenario set, order dev, cand, cand, dev: | Metric | dev 1 | cand 1 | cand 2 | dev 2 | |---|---:|---:|---:|---:| | `idle.cpu_ticks` (120 s) | 69 | 67 | 69 | 70 | | `idle.cpu_pct` | 0.575 | 0.558 | 0.575 | 0.583 | | `idle.wakeups_per_s` | 5.34 | 5.36 | 5.29 | 5.33 | | `idle.threads` | 13 | 13 | 13 | 13 | | `load.typing_cpu_pct` | 1.62 | 1.30 | 1.35 | 1.65 | | `load.typing_wakeups_per_s` | 70.0 | 66.8 | 67.1 | 71.7 | | `sync.save_ack` p50 ms | 5.56 | 4.65 | 6.39 | 5.14 | | `mem.idle` MB | 19.5 | 21.4 | 21.6 | 19.0 | | `cold.index` s | 18.0 | 16.5 | 16.6 | 16.3 | - Idle CPU, idle wake-ups, threads and typing wake-ups are flat or lower in the prod layout. There's no idle loop or watcher churn from the save-log token or the paged reconcile. - `mem.idle` is +2.0–2.6 MB (~+12%) in both cand runs. The comparator's split-state turn 2 had it at 1.002 (U 1.034), so it doesn't show in the gate layout. Two runs per arm isn't a test; I'm flagging it for the morning. Turn 3 (confirm, seed 1117, same command and binaries) started 00:41 CET.
Author
Owner

#1011 turn 3 (confirm) at 72c613833: cold.index +13.8% CONFIRMED. The PR is blocked on it (NOT READY)

Turn 3 (perf-01 FIFO ticket, measured 00:42–01:45 CET = 05:12–06:15 IST; perf-02 held by my own unit m1011-hold-tB only during the turn).

  • Same command, arms and hashes as turn 2, seed 1117.
  • 8 rounds; null block passed.

compare.py tB/layout.json --only tA/flags-plain.json (confirmation of turn 2's flags):

Cell Ratio Upper 95% MDE adj. p Result
cold.disk_written 1.0044 1.0063 0.3% 0.008 CONFIRMED (accepted: (updated, id) index, kayg 16 Nov)
cold.index / cold.notes_per_s 1.138 1.187 6.3% 0.008 CONFIRMED

Full strict family (--hot search.,cold.,sync., no layout arm):

  • Flagged: the same 3 cells.
  • Everything else is ok or unresolved, none slower. Notable cells:
    • search.cold_reconcile 1.026 (U 1.044, MDE 2.6%, ok);
    • search.query p50 0.856 and search.query_server p50 0.906;
    • search.prefix p95 0.685;
    • sync.save_ack p50 0.991 / p95 1.096 (ok).
  • All smoke cells are ok.
  • With --layout inert: INCONCLUSIVE.

Per round

  • cold.index: cand was +1.9 to +6.2 s on dev's 18.0–19.8 s in all 8 rounds, whatever its slot. dev2 and inert sat on dev except two inert outliers.
  • So my reading on the diagnostic comment (disk noise) was wrong. Two cand samples in the profile weren't enough.
  • In turn 1 (ac5669771 = cand without a36df6760) the same cell was 1.019 (U 1.036), so a36df6760 (or its LTO layout) is the prime suspect. But its title merge runs on the search writer, and the sampler saw that thread idle in the cold process.

Next (diagnostic turn queued, behind tf1b, nf3c and dav794)

  • 5 arms, mirrored, same command, seed 1118:
    • dev and dev2;
    • cand 09a246c8…;
    • ac56 c0a8602b… (cand without a36df6760);
    • sv bf070b8f… = cand + bff703553 on wip/mail1011-sv-order-1116. New source_versions tables put the 4.5 KB source column last, so page reads and the index build stop walking overflow chains. dev-01 gates: fmt, strict clippy, notes/search/calternal tests pass; notes_live had one connection-reset failure, then passed 10/10 on rerun. The size/doc guards print exactly dev's messages.
  • If ac56 is flat and cand isn't, a36df6760 gets reworked (for example the title merge after publish, off the critical path) or replaced.
  • bff703553 is not on the PR branch.
## #1011 turn 3 (confirm) at `72c613833`: `cold.index` +13.8% **CONFIRMED**. The PR is blocked on it (NOT READY) **Turn 3** (perf-01 FIFO ticket, measured 00:42–01:45 CET = 05:12–06:15 IST; perf-02 held by my own unit `m1011-hold-tB` only during the turn). - Same command, arms and hashes as turn 2, seed 1117. - 8 rounds; null block passed. `compare.py tB/layout.json --only tA/flags-plain.json` (confirmation of turn 2's flags): | Cell | Ratio | Upper 95% | MDE | adj. p | Result | |---|---:|---:|---:|---:|---| | `cold.disk_written` | 1.0044 | 1.0063 | 0.3% | 0.008 | CONFIRMED (accepted: `(updated, id)` index, kayg 16 Nov) | | **`cold.index`** / `cold.notes_per_s` | **1.138** | 1.187 | 6.3% | 0.008 | **CONFIRMED** | Full strict family (`--hot search.,cold.,sync.`, no layout arm): - Flagged: the same 3 cells. - Everything else is ok or unresolved, none slower. Notable cells: - `search.cold_reconcile` 1.026 (U 1.044, MDE 2.6%, ok); - `search.query` p50 0.856 and `search.query_server` p50 0.906; - `search.prefix` p95 0.685; - `sync.save_ack` p50 0.991 / p95 1.096 (ok). - All smoke cells are ok. - With `--layout inert`: INCONCLUSIVE. **Per round** - `cold.index`: cand was +1.9 to +6.2 s on dev's 18.0–19.8 s in **all 8 rounds**, whatever its slot. dev2 and inert sat on dev except two inert outliers. - So my reading on the diagnostic comment (disk noise) was **wrong**. Two cand samples in the profile weren't enough. - In turn 1 (`ac5669771` = cand without `a36df6760`) the same cell was 1.019 (U 1.036), so `a36df6760` (or its LTO layout) is the prime suspect. But its title merge runs on the search writer, and the sampler saw that thread idle in the cold process. **Next (diagnostic turn queued, behind tf1b, nf3c and dav794)** - 5 arms, mirrored, same command, seed 1118: - dev and dev2; - cand `09a246c8…`; - ac56 `c0a8602b…` (cand without `a36df6760`); - sv `bf070b8f…` = cand + `bff703553` on `wip/mail1011-sv-order-1116`. New `source_versions` tables put the 4.5 KB `source` column last, so page reads and the index build stop walking overflow chains. dev-01 gates: fmt, strict clippy, notes/search/calternal tests pass; `notes_live` had one connection-reset failure, then passed 10/10 on rerun. The size/doc guards print exactly dev's messages. - If ac56 is flat and cand isn't, `a36df6760` gets reworked (for example the title merge after publish, off the critical path) or replaced. - `bff703553` is not on the PR branch.
Some checks failed
Markdown extraction contract / markdown-native-contract (pull_request) Has been cancelled
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-editor-contract (pull_request) Has been cancelled
This pull request has changes conflicting with the target branch.
  • crates/notes/src/write_executor/home.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 't3/paged-search-reconcile-final:t3/paged-search-reconcile-final'
git switch 't3/paged-search-reconcile-final'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'dev'
git merge --no-ff 't3/paged-search-reconcile-final'
git switch 't3/paged-search-reconcile-final'
git rebase 'dev'
git switch 'dev'
git merge --ff-only 't3/paged-search-reconcile-final'
git switch 't3/paged-search-reconcile-final'
git rebase 'dev'
git switch 'dev'
git merge --no-ff 't3/paged-search-reconcile-final'
git switch 'dev'
git merge --squash 't3/paged-search-reconcile-final'
git switch 'dev'
git merge --ff-only 't3/paged-search-reconcile-final'
git switch 'dev'
git merge 't3/paged-search-reconcile-final'
git push origin 'dev'
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!1011
No description provided.