Repository navigation
perf(engine): repositories write side by side - #287
Merged
Merged
Conversation
Each repository's write ran one after another through a shared &mut Write that collected its branch and pull-request actions, so a run's reads, lockfile tool time and paced writes never overlapped. Write::repository now borrows the shared context and hands back its repository's actions; run_at drives the repositories through buffer_unordered and merges their actions in the same sorted repository order a sequential pass produced, so the report is byte-identical. The shared client keeps write pacing one mutation in flight per client, the lockfile runner carries one semaphore of lockfile_concurrency() across the whole run instead of a per-repository cap inside lock_all, and every piece of state a repository touched is either repository-local and merged in order or already shared safely (the governor, the notes client, the spinner). Receipts and the cache stay repository-scoped, and lockfile tool state — unique run directories, flock-guarded clone, store and cache partitions, per-bin serial locks — overlaps safely across repositories. Proof: repositories_write_side_by_side_with_an_identical_report writes three repositories with overlapping bun and npm lockfile generations, asserts the tool windows and the governor-paced writes interleave, and compares the whole report byte-for-byte against the sequential run. transcripts.tsv gains only the new test's line. The tools Overlap test parametrizes its barrier so it passes where lockfile_concurrency() < 3. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Dropping a repository mid-write could leave a published branch without its pull request. Every repository runs to the end, and the run fails with the first error in repository order, so the error does not depend on timing.
sweepies
force-pushed
the
perf/parallel-writes
branch
from
November 12, 2026 23:56
3f8ab15 to
83d2beb
Compare
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Consult 7, PR 9. A batch wrote its repositories one after another, so each repository's lockfile tools and reads waited for every earlier repository's paced writes.
Write::repositoryreturns its branch and pull request actions (Written) instead of pushing them onto shared state;Writeis a shared context.run_atdrives repositories throughbuffer_unordered(concurrency), re-sorts the results by repository (the orderlookup_work_atproduced) and merges the actions in that order, so the report is byte-identical.lockfile_concurrency()(cores, at most 4) on theRunnerreplaces the per-repository limit;lock_allloses its concurrency argument.State audit:
sentsets, stats, timings and report rows were already per repository; the notes client and spinner are mutex-guarded; receipts and the cache are repository-scoped. Clone directories, the tool store, cache partitions and per-tool serial locks incrates/toolsare flock-guarded, so tool runs may overlap: two Bun runs still serialize on their own lock, Bun and npm overlap.Behaviour on a run-aborting error (a cache failure, an invalid maintenance plan): sequentially, repositories before the failing one were written and those after it never started. Now every repository runs to the end, so none is dropped half-written (a published branch without its pull request), and the run fails with the first error in repository order. Otherwise no behaviour change: the report is identical apart from
stats, which measure the run.Proof:
repositories_write_side_by_side_with_an_identical_reportwrites three repositories (Bun, npm withnpmEngine = "npm", and one with no lockfile work) both ways. Tool windows overlap side by side and not in sequence, paced writes interleave across all three, and the two complete reports serialize byte-identically. Transcripts and depth pins are unchanged.Benchmark: on that fixture, where tool time and latency are virtual so only real work counts, the write phase took 234 ms in sequence and 172 ms side by side (medians of 5). With real tool runs the gain grows with
min(repositories, lockfile_concurrency()); Fable's estimate for ten repositories with 20 s of tool time each is 200 s → about 50 s.