Skip to content

perf(acpmux): pick session pages without cloning 3,000 keys (SW-11) - #30706

Merged
teamleaderleo merged 4 commits into
feat-cmux-nextfrom
sw11/borrow-session-list-keys
Nov 2, 2026
Merged

teamleaderleo merged 4 commits into
feat-cmux-nextfrom
sw11/borrow-session-list-keys

Conversation

@teamleaderleo

@teamleaderleo teamleaderleo commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator

SW-11: session-list paging selects borrowed keys before cloning rows

Problem

A large daemon keeps the session summaries as shared serialized text plus a compact Vec<Value> of paging keys. But both Snapshot::page and Snapshot::bounded called session_list_reply(keys.clone(), ...): even limit: 1 cloned all 3,000 keys before filtering down to one row. The owned reply implementation then discarded the unused copies. This runs on a frequently requested, paced daemon list path.

Change

  • Add session_list_reply_borrowed(&[Value], params), which filters and orders borrowed references, and clones only the selected rows into the eventual JSON reply. Keep session_list_reply(Vec<Value>,...) as a compatibility wrapper for existing call sites/tests.
  • Update the two list_guard call sites to pass their snapshot's key slice directly. The limit: 1 path now creates a borrowed-pointer selection over the N keys and deep-copies only the one selected key, rather than N (source-code-derived clone counts).
  • Preserve filtering by peer/status/localOnly/excludeStatus, both timestamp and sessionId cursor modes, stable tie ordering, nextCursor and byte-bounded row serialization. Snapshot ownership and list pacing remain unchanged.
  • For unbounded/no-limit requests, every returned row is necessarily copied once to form the reply. A later cleanup could avoid even that intermediate JSON copy by paging the text spans directly; that larger change is outside this PR.

Regression

Added three_thousand_key_snapshot_pages_only_selected_rows in list_guard.rs. It builds 3,000 snapshot keys, checks limit:1 first and next cursor, localOnly/excludeStatus/orderBy, and byte-for-byte equivalence of the existing owned API with the borrowed API for multiple filter combinations. Existing session-pages tests exercise removed/moving sessions and oversized rows. No wire/schema changes.

Performance

No perf numbers: the code removes N deep Value clones from a narrow page and copies only selected returned rows, but there is no same-harness before/after RSS, CPU or elapsed-time A/B measurement yet. The regression checks output and cursor correctness on 3,000 keys, not timing.

Validation

Capture

No capture: daemon session-list internal allocation change with identical JSON and UI.

Changelog: Paged session lists select borrowed snapshot keys, avoiding whole-keyset copies for small result pages.

SW-11 continued findings: HQ #5599.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.


Summary by cubic

Speeds up daemon session-list paging by cloning only the rows actually returned instead of the full 3,000-key snapshot.

Snapshot::page and Snapshot::bounded previously called session_list_reply(keys.clone(), ...), so even limit: 1 deep-copied every key before filtering. Both now filter and order borrowed references via the new session_list_reply_borrowed(&[Value], params) and copy only the selected rows into the reply. The owned session_list_reply remains only as a test-only wrapper; filtering, cursor modes, tie ordering, and byte-bounded serialization are unchanged.

Testing

  • Adds three_thousand_key_snapshot_pages_only_selected_rows, verifying filters, cursors, and byte-for-byte parity between the owned and borrowed APIs on a 3,000-key snapshot.
  • Updates the Snapshot::new test for the live flag.

Written for commit 088e6cc. Summary will update on new commits.

View guided diff Turn on auto-fix

@github-actions github-actions Bot added the risk:normal Risk tier (docs/ci/risk-tiers.md) label Nov 1, 2026

Copy link
Copy Markdown
Collaborator Author

SW-11 CI triage: the early api-compat red on run 41296475634 says spec/api-compat.surface.json is stale. This PR edits only hub/session_pages.rs and hub/list_guard.rs, adds an internal pub(crate) helper, and leaves all public spec files unchanged. The spec surface blob 30b68e08a37c80bb878684abc44aa3b3079f4bbd is identical at source base ab644ff... and PR head 404409e...; this is consistent with the current base's API-surface snapshot drift, not a declared protocol change in this PR. Keep the API check visible for coordinator triage; I have not regenerated unrelated generated baselines. The focused acpmux tests, format, and ordinary NEXT gates must still pass.

@blacksmith-sh

blacksmith-sh Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Found 11 test failures on Blacksmith runners:

Failures

Test View Logs
/tmp/tmp42y9sq7c/summary-fail.json (live):/summary-fail.json (live): View Logs
/tmp/tmps0kr4y1p/summary-missing.json (live):/summary-missing.json (live): View Logs
[new_workspaces] debug.new_workspace timed 0 of 50 new workspace rows/
[new_workspaces] debug.new_workspace timed 0 of 50 new workspace rows
View Logs
[new_workspaces] the window draws no frames/[new_workspaces] the window draws no frames View Logs
[tabs] debug.tab_switch timed 0 of 40 switches/
[tabs] debug.tab_switch timed 0 of 40 switches
View Logs
[tabs] the window draws no frames/[tabs] the window draws no frames View Logs
imported web bundle inputs are not routed:/imported web bundle inputs are not routed: View Logs
test_every_part_of_bun_run_check_runs_in_the_warn_branch (main.WebviewsWarnSplitCov
ersCheck.test_every_part_of_bun_run_check_runs_in_the_warn_branch)/
test_every_part_of_bun_run_check_runs_in_the_warn_branch (main.WebviewsWarnSplitCov
ersCheck.test_every_part_of_bun_run_check_runs_in_the_warn_branch)
View Logs
test_the_repository_highlights_validate (main.DigestTests.test_the_repository_highl
ights_validate)/
test_the_repository_highlights_validate (main.DigestTests.test_the_repository_highl
ights_validate)
View Logs
test_the_repository_keeps_leo_bans (main.LeoBansTests.test_the_repository_keeps_leo
_bans)/
test_the_repository_keeps_leo_bans (main.LeoBansTests.test_the_repository_keeps_leo
_bans)
View Logs

...and 1 more test failures. View all on Blacksmith

Fix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

cmux status (one comment, edited in place; each line is updated by the job that owns it)

Review 088e6cc: HQ feed card · gallery before/after runs · checks

App of this head (app.zip, kept 1 day)

gh workflow run reload-build.yml -R manaflow-ai/cmux --ref feat-cmux-next -f tag=pr30706 -f ref=sw11/borrow-session-list-keys -f platform=macos -f backend_mode=local

red: cmux-next checks (god files, concurrency, crash safety, l10n); no finished base run on dff069f to compare; do not merge until green; see lane-rules

Shipped in:

@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

Awareness note from an agent lane that does not own this PR; it is not a review or a request to take the PR over.


Taking this ChatGPT draft over for Leo's ask ask-e06a62154f (acpmux / mux-host batch): reviewing against current feat-cmux-next, then carrying it to land on a lane/ branch or closing it.

@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

Owned by an agent session · session

@cursor

cursor Bot commented Nov 2, 2026

Copy link
Copy Markdown

Bugbot needs on-demand usage enabled

Bugbot uses usage-based billing for this team and requires on-demand usage to be enabled.

A team admin can enable on-demand usage in the Cursor dashboard.

@teamleaderleo
teamleaderleo force-pushed the sw11/borrow-session-list-keys branch from 6ae8d96 to 088e6cc Compare November 2, 2026 01:47
@cursor

cursor Bot commented Nov 2, 2026

Copy link
Copy Markdown

Bugbot needs on-demand usage enabled

Bugbot uses usage-based billing for this team and requires on-demand usage to be enabled.

A team admin can enable on-demand usage in the Cursor dashboard.

@teamleaderleo
teamleaderleo merged commit 071981f into feat-cmux-next Nov 2, 2026
130 of 140 checks passed
@teamleaderleo
teamleaderleo deleted the sw11/borrow-session-list-keys branch November 2, 2026 02:01

This branch was previously deployed

1 inactive deployment
ci-routing-agent — 088e6ccd Deployed Nov 2, 2026 by teamleaderleo via cmux-tui tree preflight #98426
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:normal Risk tier (docs/ci/risk-tiers.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant