Skip to content

🤖 perf: workspace-open git/PR executeBash calls compete with the cold-open replay #4662

Description

@ThomasK33

Found while diagnosing #4624. Companion to #4661 (untrusted projects).

Problem

Even in a trusted project, opening a workspace competes with its own onChat replay:

  • Server: the renderer fires four workspace.executeBash calls for the opened workspace ~5 ms before the replay starts (GitStatusStore status script, git fetch, PRStatusStore gh pr view, gh stack view). Their four bash spawns often land in the same tick. Each fork blocks the Electron main thread for ~11-16 ms, so there is ~55 ms of continuous event-loop lag inside the replay's history read. Cold-open historyReadMs for a 31 KB epoch is ~118 ms. When the main process is idle, the same read takes ~17-48 ms.
  • Renderer: with the trusted fixture those calls finish sooner and their results render during the transcript paint. The cold-open gap from caught-up to first row grew from ~107 to ~139 ms, and dom.longestTaskMs from 87 to 146 ms (perf.chatSwitch, medians of 18 cold opens).

Trusted perf.chatSwitch medians after #4624's harness fix: cold-open-small server.totalMs 151.9, first row 388.3 ms (store switch).

Options

  1. Start the workspace-open git/PR probes after the chat is caught up. Use the existing caught-up signal, not a timer, with a fallback when it never arrives.
  2. Cut the eager calls on open: merge status and fetch into one script, and run gh stack view only when the PR is part of a stack.
  3. Reduce the fork cost in the main process (a spawn helper), which also covers 🤖 perf: untrusted projects fork git 4× per executeBash from the main process #4661.

Measure with tests/e2e/scenarios/perf.chatSwitch.spec.ts (--workers 1, summarize with bun scripts/perf/chatSwitchTable.ts artifacts/perf/electron).


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions