Skip to content

perf: cut redundant GitHub calls, subprocesses and SQLite work on warm runs - #405

Merged
sweepies merged 1 commit into
mainfrom
perf/update-tools-server-cache
Nov 24, 2026
Merged

sweepies merged 1 commit into
mainfrom
perf/update-tools-server-cache

Conversation

@sweepies

@sweepies sweepies commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

Second of three performance PRs. This one covers update, dashboard, batch, the lockfile checkout, server reload and remote auth, and the SQLite cache. It touches nothing hashed by tests/state-versions.tsv or tests/derived-versions.tsv.

Changes

Dashboard (#364). dashboard::reconcile now hashes the body without the footer, because the footer's avatar is pinned to the running release. Before this, every weekly release triggered a fresh GET and a paced PATCH on every repository's dashboard. Now an unchanged dashboard under an older footer, with LF or CRLF line endings, sends no request. A real content change still rewrites the whole body, so the footer gets updated along with it.

Batch green proofs (#388). In batch::apply, each batched PR's clean_and_green gate now runs concurrently with the others (buffer_unordered, at most 8, capped by the client's concurrency). The same goes for its tree read. automerge::clean_and_green is unchanged: each gate still re-reads its PR after ChecksQuery, so a head that moved still fails the check. As before, the base tree is fetched once and only if some PR passed. Proofs land on their items by index.

Rebasing banner (#361).

  • Lifecycle::announce and Lifecycle::clear now overlap their per-PR fresh reads and writes (buffered, at most 8). Results are applied in listing order.
  • clear still tries every PR and returns the first failure in listing order.
  • The ownership and body-changed checks are the same as before.
  • receipts.rs used to project every inventory PR just to check banner::shown. It now projects only the PRs whose body shows a banner.

Lockfile checkout.

  • A warm clone used to cost five git config runs per regeneration. It now reads git config --local --list -z once and sets only the keys that differ. A new clone is configured without the read.
  • The partial-clone settings and git's argument and environment hygiene are unchanged.
  • collect now walks generated trees on the blocking pool.

Server.

  • The settings reload walks the same local import graph that Settings::load evaluates: plain file reads, no Pkl. It re-evaluates only when the file or one of its imports changed. Evaluation reads no environment, resources or network, so those modules' text fully decides the result. That means an edit to an imported module still reloads.
  • In remote runs, the installation() and authorize() per-repository reads now overlap (at most 8). Answers are judged in request order, so the rejection still names the first failing repository.

Cache.

  • evict no longer takes a write lock when the cache is within budget. When it is over budget, it deletes in one immediate transaction instead of one autocommit per row.
  • Migration 018 indexes server_deliveries(received_at), server_installations(expires_at) and server_work(claimed, priority, available_at).
  • repositories_listed uses a HashSet.
  • The cache schema goes from 17 to 18, so the Action's cache key changes once.

Docs are updated: guide/dashboard, guide/server, internals/cache.

Tests

New tests:

  • An older-version footer sends no request, and a content change sends a GET then a PATCH with the new body (tests/dashboard.rs).
  • Banners on four PRs come down together, checked by counting how many PR reads are in flight at once (tests/write.rs, plus its transcript row).
  • The warm checkout reads the config once and writes only the URL (real_git_cache…). Also a unit test for local_config.
  • Reload skips unchanged modules and still follows imports.
  • EXPLAIN QUERY PLAN shows the server scans use migration 018's indexes.

On the boat VM:

  • clippy -D warnings is clean.
  • cargo test -p patchula-cache -p patchula-update -p patchula-tools -p patchula-server passes, run with --skip lockfiles::tests::real_.
  • real_git_cache_is_reused_and_fetches_new_bases_incrementally_offline passes.
  • cargo test -p patchula-engine -p patchula-cli passes. The depth pins didn't change.

Locally, hk check passes on the changed files with the clippy step skipped (clippy was run on the VM).

Follow-ups (not done here)

  • Using the memoised notes_source_repository on a lasting release-notes failure would mean making it public in crates/notes/src/lib.rs. That tree is hashed by the changelog row of tests/state-versions.tsv, so it is left for a change that can bump that row.
  • Bodies::compose is still computed separately by ranges, the reuse check and draft. Sharing it across their different lifetimes was not clean enough for this PR.
  • Runner::installed reads one small JSON file. Moving it to spawn_blocking would cost about as much as it saves, so it is left alone.

View guided diff Turn on auto-fix

…m runs

- dashboard: compare bodies without the release-pinned footer, so a new
  release alone no longer re-reads and rewrites every dashboard
- batch: run each batched PR's green gate and tree read concurrently
  (bounded); each gate still re-reads its PR after the checks
- pull requests: put rebasing banners up and take them down concurrently,
  applying results in listing order; check for a bannered PR without
  projecting every PR in the inventory
- lockfiles: read a warm clone's config once and set only keys that
  differ, instead of five git runs per regeneration; walk generated trees
  on the blocking pool
- server: skip settings evaluation while the file and its local imports
  are unchanged; run remote-run installation and permission reads
  concurrently, judged in request order
- cache: evict in one immediate transaction, only when over budget; index
  the server queue, delivery and installation scans (migration 018); use a
  set when pruning listed repositories
@sweepies
sweepies marked this pull request as draft November 24, 2026 06:19
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
count-patchula 64a1450 Commit Preview URL

Branch Preview URL
Nov 24 2026, 06:19 AM

@sweepies
sweepies marked this pull request as ready for review November 24, 2026 06:36
@sweepies
sweepies merged commit 88e994e into main Nov 24, 2026
13 checks passed
@sweepies
sweepies deleted the perf/update-tools-server-cache branch November 24, 2026 18:39
@sweepies-ops sweepies-ops Bot mentioned this pull request Nov 24, 2026
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