Skip to content

Pre-warmed worktree pool for instant thread creation #192

Closed

Description

@currentbits

What Emdash does

A pre-warmed worktree pool: a reserve worktree is claimed and renamed on task creation, skipping the 3-7s worktree add (docs).

Solenta today

setupWorktree (electron/worktrees.js:524-525) creates the worktree synchronously on demand, every time.

Why it matters

On large repos, worktree creation (plus setup scripts and .env copying once those land) is the dead time between "I have an idea" and "agent is running." A background pool makes new threads feel instant in the "fire off five threads" workflow Solenta targets.

Fix direction

Keep N idle worktrees per project, refreshed in the background; claim + rename on thread creation, with the sync path as fallback when the pool is empty.

Activity

  1. added
    enhancement
    plan:todo
    on Aug 16, 2026
  2. currentbits commented on Aug 17, 2026

    @currentbits
    OwnerAuthor

    Research note (Jules Environment Snapshots, Codex/Claude setup caches, Conductor per-workspace run environments): besides pre-warmed worktrees, cache the environment setup per repo (deps installed, build warmed) so a new thread skips install entirely. Jules exposes this as a named feature ('Run and Snapshot'); a broken snapshot must never go live (fall back to last good, per Cursor Builds).

  3. currentbits commented on Aug 17, 2026

    @currentbits
    OwnerAuthor

    Research note (Vercel Drives / Northflank): decouple caches from worktree lifecycle. A per-project shared cache volume (node_modules, build caches) mounted into every worktree run and surviving worktree deletion is the big real-world speedup; pairs with the env snapshot idea above.

  4. currentbits commented on Aug 18, 2026

    @currentbits
    OwnerAuthor

    Research note: Cursor shipped Builds (Aug 13) — exactly this pattern: pre-warmed environment copies prepared in the background, 3x faster time-to-first-token, and crucially 'a broken build never becomes active; agents keep using the last successful build'. Build history tab shows which build each agent run used. The last-good-fallback and per-run build attribution are now table stakes for env snapshots.

  5. currentbits commented on Aug 18, 2026

    @currentbits
    OwnerAuthor

    Round-19: Cursor Builds (13 Aug, https://cursor.com/changelog/08-13-26) is the cloud version of this issue, with one extra rule we should steal.

    They continuously prepare a ready environment (deps installed, install script already run) and boot agents from it. Internally they claim 10x faster env boot and 3x faster time-to-first-token. The important part is not the speed:

    When a bad commit or dependency update breaks your environment, agents keep using the last successful build. The broken build never becomes active.

    A local worktree pool that only does claim+rename (#192 as written) still starts agents in a red setup the moment main goes bad. The local analog is: keep N ready worktrees and refuse to promote a setup that failed its own probe (install script, typecheck, whatever #153/#282 define). Agents keep the last green snapshot; the user gets a notification; we do not silently hand them a broken tree.

    Also pairs with #396 (honor the repo env spec) — the install command is what the Build runs.

  6. currentbits commented on Aug 18, 2026

    @currentbits
    OwnerAuthor

    Round 19 intel: Cursor Cloud Agents Builds (changelog 2026-08-13) is the mature version of environment pre-warming, with two ideas beyond a warm pool:

    1. Resilient pinning: a new build that fails never becomes active. Agents keep booting from the last successful build and the user is notified of the breakage in the background. A bad commit or dep update can no longer break every new session.
    2. Build provenance: a Builds tab shows status, logs, commit SHAs, and which build each agent run used. When a run misbehaves, you can tell whether the environment changed under it.

    For Solenta's worktree pool: warm worktrees should record their provenance (base SHA, setup-script run, timestamp) on the thread, and a failed setup script on a warm worktree should poison that worktree, not the pool. Related: #153, #396, and #511 (no silent fallback).

  7. currentbits commented on Oct 1, 2026

    @currentbits
    OwnerAuthor

    2026-10-01 local measurement: git worktree add --detach /private/tmp/solenta-worktree-perf-4bbd0820 HEAD on the Solenta checkout took 0.20 s wall time; removal took 0.11 s. captureLeadSnapshot took 13.5 ms median over 15 runs. The live app has 0/12 projects with setupCommand configured. A pool of bare worktrees would therefore save little in this workload while adding persistent disk use and refresh/cleanup state. Keep this idea for a repo where measured checkout/setup dominates time to first token; benchmark dependency setup separately before pursuing environment snapshots.

  8. currentbits commented on Oct 1, 2026

    @currentbits
    OwnerAuthor

    Additional live disk measurement (2026-10-01): across 21 current worktree directories, 14 real node_modules directories use 5.3 GiB; four other dependency directories are symlinks. This supports the earlier comments that dependency reuse could save more disk/setup than prewarming a bare Git checkout. It is an aggregate read-only measurement; no dependency cache design or time-to-first-token improvement was tested.

  9. added
    plan:doing
    and removed
    plan:todo
    on Oct 10, 2026
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

    enhancementplan:doing

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions