Skip to content

Cloud start: read a new machine's state 1 s apart and stop waiting as soon as it runs - #35023

Merged
teamleaderleo merged 1 commit into
feat-cmux-nextfrom
lane/cloud-start-faster-wait
Nov 4, 2026
Merged

teamleaderleo merged 1 commit into
feat-cmux-nextfrom
lane/cloud-start-faster-wait

Conversation

@teamleaderleo

@teamleaderleo teamleaderleo commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Leo-ask: ask-e09ceb4656

Leo, 2026-11-04: "why is it taking so long to start a chat "in cloud"?"

Why it takes long

Every first send from a Mac workspace that has no Cloud machine yet makes a new machine (one workspace per small Cloud machine, #30020), so the wait is mostly that machine starting. On top of that, the client wasted time:

  • While a new machine provisioned, CloudMove.connected slept 3 s before every read, the first included, then did a full list read. A machine that came up just after a read was seen up to 3 s late.

This change

  • The first 20 reads are 1 s apart, then 3 s (80 reads, about 3 min, up from 60 × 3 s).
  • Each pause ends as soon as any other read (the change tracker's refresh, a list read) shows the machine running, and then no extra list read is made.
  • Cancelling the start still ends the wait at once.

Expected saving: about 1–3 s per first send that makes a machine (average lag after the machine runs goes from ~1.5 s + the 3 s first sleep to ~0.5 s). Not measured on a real start yet; the larger fixes for this ask are the prewarm PRs already open (#34974 prewarm while typing, #34487 warm on composer select), which start the machine before Send.

Risk: low. One wait loop's pacing; a provisioning machine now costs up to 20 extra list reads in its first 20 s.

Test: CloudMachineChangeStateTests.aStartWaitsForANewMachineToRun gains a case: a machine seen running during a pause is not read again.

Agent session: agent session

🤖 Generated with Claude Code


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


Summary by cubic

Speeds up the first send from a Mac workspace that provisions a new Cloud machine. Previously CloudMove slept 3 s before every state read (the first included), so a machine that came up just after a read was seen up to 3 s late.

  • Reads 1 s apart for the first 20 reads, then 3 s (80 reads, about 3 min) instead of 60 reads at 3 s.
  • Stops waiting as soon as any read shows the machine running, with no extra list read; cancelling still ends the wait immediately.

Written for commit d26c8e7. Summary will update on new commits.

View guided diff Turn on auto-fix

…s soon as it runs

A new machine's wait slept 3 s before every read, the first one included, so
a start lost up to 3 s after the machine already ran. Now the first 20 reads
are 1 s apart (then 3 s, about 3 min in all), and a pause ends as soon as any
other read shows the machine running, with no extra list read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Session: https://cmux.com/deeplink/agent?id=aid-2281e166aee16df17217
@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

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

Review d26c8e7: 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=pr35023 -f ref=lane/cloud-start-faster-wait -f platform=macos -f backend_mode=local

Shipped in:

@teamleaderleo teamleaderleo left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review (claude-opus-5-5): SHIP at d26c8e7

Review (subagent claude-opus-5-5 medium): SHIP at d26c8e7

Checked Swift 6 isolation (the condition closure captures session like CloudHandlers.swift:363), that machine.status only becomes .running from a server record applied through listed/applyRecord (so skipping the forced read loses nothing), cancellation (CloudWait.holds returns, checkCancellation throws, untilRunning returns), the wakeup-allow lint (the only direct sleep is gone), and the new test case (old code reads once, new code zero times). check-concurrency.sh passes.

Follow-ups: [follow-up] the longest wait is about 200 s, up from 180 s, with up to 20 reads in the first 20 s of a new machine (not blocking).

@teamleaderleo
teamleaderleo merged commit 384ecc9 into feat-cmux-next Nov 4, 2026
159 of 177 checks passed
@teamleaderleo
teamleaderleo deleted the lane/cloud-start-faster-wait branch November 4, 2026 07:19
@blacksmith-sh

blacksmith-sh Bot commented Nov 4, 2026

Copy link
Copy Markdown

Found 6 test failures on Blacksmith runners:

Failures

Test View Logs
/tmp/tmpc5ig2s6c/summary-missing.json (live):/summary-missing.json (live): View Logs
/tmp/tmpdwk6thlu/summary-fail.json (live):/summary-fail.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

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

This branch was previously deployed

1 inactive deployment
ci-routing-agent — d26c8e74 Deployed Nov 4, 2026 by teamleaderleo via wait for same-key tree publisher #110324
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