Repository navigation
perf(picker): take the path seed and forge lookup off the collect thread - #4288
Conversation
Between the picker's skeleton and the ref snapshot, the collect thread ran two serial steps: `prime_worktree_path_caches` (a canonicalize and a `.git` read per worktree) and, when a row's cached CI status carried a PR, the comments spawn's `ci_platform()` call, whose first use forks `git remote get-url`. On leaf (≈130 worktrees) under load these took 75ms together; the snapshot could not start until both returned. The seed now runs as a spawn in the post-skeleton scope, overlapping the snapshot, with the fsmonitor probes nested under it because each probe reads the git dir it seeds. The comments spawn resolves the forge inside its pool job, through the same `spawn_comments_fetch` path the `--prs` rows use, so `on_skeleton` and `on_update` do no I/O. That removes the last production caller of `fill_external`; tests call `fill` directly. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
# Conflicts: # src/commands/list/collect/mod.rs
worktrunk-bot
left a comment
There was a problem hiding this comment.
codecov/patch fails because of the three lines at collect/mod.rs:1762-1764: the s.spawn(|_| repo.start_fsmonitor_daemon_at(&wt.path)) loop. That loop was only moved inside the seed spawn, and it was already uncovered on main. fsmonitor_worktrees is empty on every platform except macOS, and coverage runs on Linux. None of the PR's new logic is missed: prs.rs, preview_orchestrator.rs, and progressive_handler.rs are at 100% patch coverage.
Adding a test can't close this gap, so there's nothing to change in the code. Per AGENTS.md, merging with a failing codecov/patch needs your explicit sign-off, so I'm withdrawing my approval until you decide. My review of the code itself found no issues.
codecov/patch failing (moved macOS-only lines); needs maintainer sign-off per AGENTS.md
After the picker paints its rows, the collect thread ran two steps one after the other before the ref snapshot could start. The task pool opens only once that snapshot finishes, so every row's results waited on both steps:
prime_worktree_path_caches, which canonicalizes and reads.gitfor each worktree: 5–7ms warm, 20–82ms loaded or cold on leaf (~130 worktrees).ci_platform()call, whose first use forksgit remote get-url: 20–48ms. It runs only when a row's cached CI status is still fresh (within 30–60s of awt list).The seeding now runs as a spawn in the post-skeleton
rayon::scope, alongside the ref snapshot. The fsmonitor probes are nested under it because each probe reads the git dir the seeding fills in. The comments fetch now resolves the forge inside its pool job, through the samespawn_comments_fetchpath the--prsrows use, soon_skeletonandon_updatestart no processes. That removes the last production caller offill_external; tests callfilldirectly.In a trace with a fresh CI cache,
mainspends 93→168ms on these two steps before the snapshot starts. On this branch the snapshot starts at the skeleton handoff. The expected saving is ~10ms on an idle machine and up to ~130ms under load. An end-to-end timing wasn't possible: the load average was 55–164 during the runs, and time to pool start varied 430–660ms on both builds, mostly from the snapshot's ownfor-each-refscans.The pipeline diagram in
src/commands/list/collect/mod.rsis updated to show where both steps now run.🤖 Generated with Claude Code