Skip to content

perf(who): look up each T3 thread directory's checkout once - #125

Merged
bompus merged 1 commit into
mainfrom
fix/who-checkout-cache
Oct 10, 2026
Merged

bompus merged 1 commit into
mainfrom
fix/who-checkout-cache

Conversation

@bompus

@bompus bompus commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

swarmail who ran git rev-parse for every running T3 thread that was not in the roster. Those threads share far fewer directories than there are threads: on this machine 793 running threads use 149 directories.

whoRows now remembers the answer per directory for the length of one call.

Measured with hyperfine-style wall time on the same machine and T3 state:

before after
swarmail who --json 1.63 s 0.30 s
rows returned 82 82

A CPU profile of the old command put 94% of its time in spawnSync for git. The new test fails without the change (git is asked four times for two directories) and passes with it. bun run check and the full suite (1215 pass, 0 fail) pass.

Behavior is unchanged except for one case: if a directory's checkout changes while a single who call runs, the call keeps the first answer.

Summary by CodeRabbit

  • Performance
    • swarmail who now checks Git once per distinct running T3 thread directory, reducing repeated checks. A recorded example improved from 1.6 seconds to 0.3 seconds.

`swarmail who` spawned git for every running T3 thread that was not in the
roster, although the threads share far fewer directories. With about 800 running
threads in 149 directories it took 1.6 s, 94% of it in git spawns. It now asks
once per directory and takes 0.3 s with the same 82 rows.
@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Review in Change Stack →Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository YAML (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b3ff1156-d198-4e95-844e-1d0cdc7d816d

📥 Commits

Reviewing files that changed from the base of the PR and between 6b5c7ae and 3451ca6.


📒 Files selected for processing (3)
  • CHANGELOG.md
  • src/who.ts
  • test/who.test.js

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.



📝 Walkthrough

Walkthrough

whoRows now caches checkout resolution by thread directory. The test checks that repeated directories trigger one checkout lookup each, and the changelog records the change and an example timing comparison.

Changes

Thread checkout matching

Layer / File(s) Summary
Memoize checkout resolution
src/who.ts, test/who.test.js, CHANGELOG.md
whoRows caches checkout results by directory, including null results, and uses them when matching running, unclaimed threads. The test checks lookup counts and matching rows. The changelog records the change and an example timing comparison.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 3451c

Repeated thread directories now share a checkout lookup without changing the matching behavior. No actionable merge-blocking risk is evident.

Pre-merge checks | Passed 6
✅ Passed checks (6 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main performance change: resolving each T3 thread directory's checkout once.
Description check Passed The description explains the change and motivation, reports measured performance, documents unchanged behavior and the one timing-related behavior difference, confirms test results, and supports the r…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Suppressions Explained Passed The pull request adds no lint, type-check, or formatter suppression directive. The changed lines only add checkout memoization, a test, and changelog text.
Interface Changes Documented Passed PASS: The pull-request diff changes checkout memoization in src/who.ts, adds a test, and adds an ## Unreleased changelog entry. It does not add, remove, or rename an MCP tool or argument, a `swarm…


✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR


🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR


  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@bompus
bompus merged commit f280ef2 into main Oct 10, 2026
3 checks passed
@bompus
bompus deleted the fix/who-checkout-cache branch October 10, 2026 01:45
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