Skip to content

test(perf): session-entries (#43932) and sender-index (#43768) flow contracts with exact work deltas - #44758

Merged
brennanb2025 merged 1 commit into
mainfrom
brennanb2025/perf-flow-budgets
Nov 20, 2026
Merged

brennanb2025 merged 1 commit into
mainfrom
brennanb2025/perf-flow-budgets

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Runs in CI?

Yes. Both files are *.performance.test.ts, so the existing performance-contracts.yml job selects them on every production change. The regular unit suite also picks them up through src/**/*.test.ts. The PR adds no new job and no new workflow.

  • What runs: two count-only Vitest contracts. They make no wall-time assertions and start no Electron, builds or fleet gate. Fake timers drive the save debounce.

  • Measured cost: this was re-measured after ci(perf): run performance-contract files in parallel #44771 made contract files run in parallel. The table gives the contracts step, as the median of 3 GitHub runs each on main commit 6480d9f, alone and with this PR's two files:

    OS main main + this PR Added
    ubuntu 52 s 58 s about +6 s (+9 s by mean)
    Windows 86 s 92 s about +6 s (+10 s by mean)
    macOS 111 s 80 s within runner noise (individual runs ranged 68–155 s)

    The earlier +40 s per OS was measured when contract files still ran one at a time. The session contract now shares workers with the other contracts, and the existing store contract already loads the same renderer store code. All 9 runs with this PR's files passed on current main.

  • The fleet perf gate still doesn't run in CI.

Problem

These are flow budgets for the fleet-size class from the previous PR: work that grows with the number of worktrees or rows when only one changed. Two recent fixes are in that class:

Change

Two contracts, written the same way as the previous PR: one fleet of 100, warm up, snapshot the counters, act once, and assert the exact delta.

  • Session entries (perf(session): send only the workspace entries a window changed since main acknowledged them #43932), workspace-session-host-persistence.performance.test.ts:
    • Setup: 100 worktrees with two tabs each, made through the store's real createTab, so unified tabs, groups and layouts exist. Saves go through the real createSessionWriteSubscriber → patchWorkspaceSessionByHost with acknowledged entries.
    • Counter: a fake SessionApi counts writes and every entry sent, both through patchEntries and through the whole-field patch fallback. That way, falling back to whole fields can't hide.
    • Result: one tab switch sends +1 write, +4 entries and rebuilds 1 worktree tab session. The rebuild count comes from a call-through spy on structuredLaunchSlotIds, which runs once per group of each rebuilt session.
  • Sender index (perf(agent-senders): stop rebuilding a host's sender index for unchanged and single-scope updates #43768), agent-sender-index.performance.test.ts:
    • Setup: a 100-row whole-host publication, plus one worktree scope.

    • Counter: a call-through spy on HostPartDraft.prototype.rows counts the rows handed to the host's sender index, whether it edits the previous index or rebuilds it. Setup is pinned at 101.

    • Result (counted per step):

      Step Rows
      Repeated whole-host delivery 0
      One scope change 2
      Repeated scope 0
      A new scope appears 2
      That scope leaves 2

What this does and doesn't cover: the contracts bound the entries sent, the session rebuilds and the sender rows joined in these two flows. They don't cover these:

  • Overlay-map sharing in the sender index: folding on every edit costs CPU but doesn't change the row counts.
  • Attachment principals: the fixture has no attachments.
  • The app hook's wiring: the test assembles the same subscriber and acknowledged entries itself, so dropping the acknowledged entries from use-app-session-persistence.ts would not fail it.

Proof

The contracts fail when their fixes are reverted. Both runs were local, and the code was restored afterwards:

Change Expected Got
Send whole session fields on every write +4 entries (810 total) 1307 total
Remove the per-worktree tab-session cache (cache?.set) 1 session rebuilt 100
Rebuild the sender host part on every change {0, 2, 0, 2, 2} fails
Drop the unchanged short-circuit for a repeated whole-host delivery 0 rows 101

Standard-approach check: VERDICT: STANDARD. The pattern matches what similar projects do: a counting fake at the I/O boundary, spies with exact counts, one large fixture with a single change, and a before/after delta. Nothing is timed.

Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​197 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​197
Prod 0 0 0 0

@brennanb2025
brennanb2025 marked this pull request as ready for review November 19, 2026 15:12
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change adds two performance-contract tests. One measures workspace-session writes and saved tab-session work after switching the active tab with 100 worktrees. The other measures sender-index row joins during whole-host and scoped publication deliveries across 100 worktrees.

Merge Risk: Minimal · up to 51cd2

This change adds tests that bound the persistence and sender-index work for a single change across 100 worktrees. It does not alter runtime behavior, so merge risk is minimal.

Pre-merge checks: Passed 3 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Description check Warning The description is detailed and covers most required content. It has a clear problem statement, a change summary with measured results, a risk-relevant CI cost analysis, a proof table showing the cont… Add the missing template sections: (1) an ELI5 summary in plain language; (2) rename the problem and change content to 'What Changed' and 'Why', including why this approach beats the alternatives; (3) fill in the Linked Issue with an actual…
Passed Passed checks: 3 passed

Check name Status Explanation
Title check Passed The title is a conventional test-scoped commit-style title that names the two performance-contract tests and their purpose: exact work deltas for the session-entries (#43932) and sender-index (#43768)…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title is a conventional test-scoped commit-style title that names the two performance-contract tests and their purpose: exact work deltas for the session-entries (#43932) and sender-index (#43768) flows. It matches the changeset, which adds two count-only performance tests for those flows. It is long (100 characters) and uses issue numbers, but it describes the main change accurately.

Full details: Description check

Explanation

The description is detailed and covers most required content. It has a clear problem statement, a change summary with measured results, a risk-relevant CI cost analysis, a proof table showing the contracts fail when fixes are reverted, and explicit scope limits. It follows the template's intent but departs from the template's headings. It has no ELI5 section, no 'What Changed' or 'Why' headings in template form, no Linked Issue (the template says there should always be one for outside contributors and the 'Fixes #' line is blank), no Visual Proof section (N/A with reason is expected for test-only changes), no explicit Risk section with a Level, and no Review/Agent skill boundary or Checklist. The Testing checkboxes are not ticked, and the 'Automated tests added' item is effectively satisfied but unmarked. The Notes section is not addressed in the template's terms for Security, Mobile, or backwards compatibility.

Resolution

Add the missing template sections: (1) an ELI5 summary in plain language; (2) rename the problem and change content to 'What Changed' and 'Why', including why this approach beats the alternatives; (3) fill in the Linked Issue with an actual issue number or explain why none applies, since the template requires one for outside contributors and 'Fixes #' is blank; (4) add a Visual Proof section stating N/A and the reason, since this is test-only; (5) add a Risk section with a Level (Low is likely appropriate) and a rollback note (a plain revert); (6) state the AI Disclosure if an AI model was used, since the PR includes an AI-generated summary and a 'VERDICT: STANDARD' check; (7) complete the Testing checkboxes or explain why any are unchecked; (8) address the Notes items (security, cross-platform, SSH, mobile, backwards compatibility, performance) explicitly; (9) complete the Agent skill upstream boundary checkbox; (10) tick the Checklist items that apply.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f75e78a6-4ab8-4990-b1b8-2db29a839968
Commits

Reviewing files that changed from the base of the PR and between c34c424 and 51cd266.

Files selected for processing: 2

  • src/renderer/src/lib/workspace/persistence/workspace-session-host-persistence.performance.test.ts
  • src/renderer/src/runtime/native-chat/agent-senders/agent-sender-index.performance.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status: ready

Reviews:

  • Three rounds of fresh Claude + Codex reviews.
    • Round 1: the session fixture gained real unified tabs, and the sender fixture gained a whole-host baseline. A private-state accessor was replaced with a prototype spy.
    • Round 2: added the scope appear and leave steps, the pinned setup total, and the tab-session rebuild counter. That counter catches a cache revert the entry count missed.
    • Round 3 came back READY from both. The only follow-up was a one-line JSDoc nit, now fixed in 51cd266.
  • CodeRabbit: no actionable comments.

Standard-approach and reference comparison (whole PR): VERDICT: STANDARD. The design is a counting fake at the I/O boundary plus spies with exact counts. The fixture is one large fleet, the test makes a single change, and it asserts the before/after delta. Nothing is timed.

remote-check: PASS on 4bf8aac (Omarchy, lane pg3-2). Since then, the only change is the JSDoc line.

CI: green. The performance-contracts step adds about +40 s on ubuntu, +40 s on macOS and +37 s on Windows (table in the PR body). Almost all of it is transforming the renderer store graph that the session contract drives through the real wiring.

QA: qa=none. This is a test-only PR. Each contract fails when its fix is reverted:

Fix reverted Expected Got
Whole session fields sent on every write 810 entries 1307
Per-worktree tab-session cache removed 1 rebuild 100
Sender host part rebuilt on every change exact row counts fails
Short-circuit for an unchanged whole-host delivery removed 0 rows 101

@brennanb2025
brennanb2025 merged commit e7e85a5 into main Nov 20, 2026
69 of 70 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant