Repository navigation
feat(infra): hosts and company boxes get a full vCPU, and the fleet runs 24 boxes - #984
Merged
Merged
Conversation
This was referenced Oct 28, 2026
Merged
allisonmahmood
added a commit
that referenced
this pull request
Oct 29, 2026
) ## What changed A box's first tier 2 process took 1.8 s to start in production (p50), while a respawn of the same version took 0.5 s. Most of the gap was the supervisor bundling its own loader worker with esbuild the first time it started a process. On half a vCPU, esbuild's threads exhaust the CFS quota and stall. The CLI already shipped this worker prebuilt; services didn't. The execution package's build now bundles the loader into `dist/loader.js` (`scripts/build-execution-loader.mjs`, run after `tsc`, like the serving broker's build), and built code always reads it. Only a source checkout (dev and tests) still bundles on first use. That makes the `__PATCHY_PACKED_LOADER__` define the CLI build set unnecessary, so it's removed. esbuild and es-module-lexer become dev dependencies and leave the server image. The image build now checks that the staged loader's only import is `cloudflare:workers`, so an unbundled loader can't ship. This also speeds up the host's first bundle inspection, which starts a workerd through the same path. ## Look at The real supervisor (compiled, as the image runs it) binding a real tier 2 bundle (New Business from `brightline`, 226 KiB) under a CFS quota on two pinned CPUs. Medians of 7 interleaved runs each: | | main | this PR | | --- | --- | --- | | First process on a box, 0.5 vCPU | 1,283 ms | **419 ms** | | Respawn, 0.5 vCPU | 402 ms | 407 ms | | First process on a box, 1 vCPU | 633 ms | **199 ms** | | Respawn, 1 vCPU | 202 ms | 217 ms | A box's first process now costs the same as any other. This machine's cores are about 1.5× Fargate's (main's 402 ms respawn here vs 468 ms p50 in production), so production should see the first process drop from ~1.8 s to ~0.5 s on today's 0.5 vCPU boxes, and to ~0.3 s on 1 vCPU (#984). The esbuild step alone, timed from a cold Node process the way a box runs it: ``` CPUQuota=50%, 2 CPUs: build 403 / 449 / 460 ms CPUQuota=100%, 2 CPUs: build 207 / 239 / 263 ms ``` ## How it was verified - Staged the image runtime (`node scripts/build-server-image.mjs --stage`) with no esbuild in it, then bound both brightline tier 2 bundles through its supervisor: first process 225 ms, second version 252 ms, respawn 208 ms (unthrottled). - The staging check rejects tsc's unbundled `loader.js` and accepts the built one. - `Process`, `Engine` and `Inspection` tests pass from source (the dev path, which still bundles). - CI's packed CLI e2e covers the CLI's own `dist/loader.js`, which it now reads without the define. Not measured: production's cold page cache for the 133 MB workerd binary. It cost 10–20 ms here on local NVMe. ## Release impact - [ ] **Breaking** — requires action from anyone already running this - [x] **Not breaking** — no action required Build output only: the image ships the loader prebuilt instead of the bundler that made it. - **What does a revert leave behind?** Nothing. The previous image bundles at first use, as it always did. - **Does the release before it still work with that?** Yes. No wire, schema or configuration change. Made by Claude Opus 5.5 via Claude Code; reviewed with GPT-6.1-Sol. Co-authored-by: Claude Opus 5.5 <[email protected]>
…uns 24 boxes Rebased onto main after the TypeScript 7 stack (#985). Co-Authored-By: Claude Opus 5.5 <[email protected]>
allisonmahmood
force-pushed
the
t3/scale-fleet-vcpu
branch
from
October 29, 2026 16:22
bfaec74 to
841ef8a
Compare
allisonmahmood
added a commit
that referenced
this pull request
Oct 29, 2026
…orecast passes $600 (#990) ## What changed The production budget emails when the month's forecast passes $300. With full-vCPU hosts and company boxes (#984), idle infrastructure alone is about $180 a month, so that alert will fire on ordinary busy weeks. This keeps the $300 alert exactly as it is and adds a second one, a new budget that emails when the forecast passes $600. ## Look at - **Two budgets, not two notifications on one.** CloudFormation replaces an `AWS::Budgets::Budget` to change its notifications, and the replacement would collide with the fixed `patchy-monthly` name and fail the base stack deploy (caught in review). The $600 alert is its own budget, `patchy-monthly-600`; `apps/infra/src/BaseStack.ts` builds both from one helper. - **The $300 budget doesn't change at all.** Synthesizing the production base stack on main and on this branch gives an identical `Spend` resource, so the deploy only creates `SpendHigh`: ``` main ids: ['Spend'] branch ids: ['Spend', 'SpendHigh'] Spend identical on branch: True ``` - **Email verification.** AWS Budgets emails a newly added address only once it is verified in the account, and one verification covers every budget. Addresses already verified in the account are active at once, and recipients added before AWS introduced verification keep receiving alerts unchanged. So the alert addresses may get a verification email from an `@aws.com` sender when the new budget appears; open its link while signed in to the account. `docs/OPERATIONS.md` records both budgets, why each alert is its own budget, and the verification step. ## How it was verified - `vitest run src/stacks.test.ts` in `apps/infra`: 7 passed. The new case pins exactly two budgets, each one's name, type, period, amount, its forecast-above-100% notification and its email subscriber. - The identical-`Spend` comparison above, from the synthesized templates. - Prettier, ESLint and `tsc` on the infra package. - Not checked: the deploy itself and the email; both happen on the next release. ## Release impact - [ ] **Breaking** — requires action from anyone already running this - [x] **Not breaking** — no action required Infrastructure only: one new AWS budget in the production base stack. The existing budget is untouched. - **What does a revert leave behind?** Nothing: the base stack deletes `patchy-monthly-600` on its next deploy, and `patchy-monthly` is unchanged either way. - **Does the release before it still work with that?** Yes. Releases don't read budgets. Made by Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, running in T3 Code. Co-authored-by: Claude Opus 5.5 <[email protected]>
1 of 2 tasks
allisonmahmood
added a commit
that referenced
this pull request
Oct 29, 2026
## What changed This adds release 23's What's new entry, written from `ed80fc7`. It covers everything merged since release 22's `through` (`a2d1331`), and sets the `patchy` release to `0.23.0` in `packages/patchy/package.json` and `CURRENT_RELEASE`. This is the speed and capacity release: patches that run server code open faster, and the fleet has room for more companies at once. | Change | PRs | | --- | --- | | Improved: Patches with server code open faster. Landing on Home or All patches readies the company's server and its three most-opened patches, a patch stays ready for ten minutes after use instead of one, loading a patch takes a third of the time, and each company server has twice the CPU | #991, #992, #997, #999, #984 | | Behind the scenes: Patchy can run patches for more companies at the same time (24 company boxes instead of 15, and 64 companies per host instead of 16) | #984, #993 | Two merged PRs get no line, because nobody using Patchy would notice them: #990 (a second AWS cost alert, at $600) is operations tooling, and #1049 (a test fix for flake #1012) is test churn. #1046 is release 22's own entry. ## Look at - **The entry**, at the top of `releases` in `packages/core/src/whatsNew.ts`. - **Rollback safety, from the live commit `eb414ed` (release 22) to `ed80fc7`:** - No PR in the range is labelled `one-way`, and none adds a migration. - #984 and #990 change infrastructure. A rollback redeploys release 22's stacks: 0.5 vCPU tasks, a fleet budget of 15 with two spares, and no `patchy-monthly-600` budget (the base stack deletes it; `patchy-monthly` is untouched). Exec task definitions are retained, so release 22's hosts can still manage this release's boxes until promotion. - #984's one rollback hazard: once this release holds 14 or more spare boxes, release 22 can't fit its two spares inside its budget of 15, and its promote step times out. The fix is the runbook in `docs/OPERATIONS.md` › Freeing budget for a promotion. - #999 leaves binding history rows with release cause `unused`, which release 22 reads as text. #999's new `speculative` bind field is refused by release 22's supervisors before they act, so prewarms on those boxes are skipped during a rolling deploy. - Neither `execution.process.load` (#992) nor `execution.prewarm.window` (#999) is set in production's `PATCHY_LIMITS_JSON`, so release 22 loads the configuration unchanged. **Rollback line:** If this release misbehaves, roll back to `eb414ed` (release 22). If that rollback's promote step times out short of two spares, follow `docs/OPERATIONS.md` › Freeing budget for a promotion, then re-run it. ## How it was verified - **Tests.** `whatsNew.test.ts`, `WhatsNewPages.test.ts` and `schemas.test.ts` pass (21 tests), and prettier passes on the changed files. - **The range.** Each PR was Sol-reviewed with every finding fixed. After the TypeScript 7 stack (#985), all seven were rebuilt on one integration branch, with each conflict and each TypeScript 7 fix kept in the PR it belongs to. `pnpm check` passed there, apart from local-only CLI and supervisor test failures caused by T3 probing this machine's ports. Each PR then landed with all 12 required checks green on its rebased head, and main's tree after #990 equals the integration tip. Re-runs: `clerk-live` once on #984 (a sign-in handshake flake). On #992, flake #1012 failed twice and was fixed by #1049 instead of re-running. - **Deploy state.** The live commit, pinned from `/healthz/deep`, is `eb414ed` (release 22). The Deploy run updated last succeeded, and none is unfinished. - **Quota.** #984 peaks at 29 vCPUs during a deploy (24 boxes, 4 rolling hosts, the promote task), inside the account's current 30. ## Release impact - [ ] **Breaking** — requires action from anyone already running this - [x] **Not breaking** — no action required Text and version numbers only. The `0.23.0` bump tells CLIs and patch repos installed before this deploy to upgrade, as every release does. - **What does a revert leave behind?** Nothing. - **Does the release before it still work with that?** Yes. Made by Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, running in T3 Code. Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
What changed
Company boxes and hosts ran on half a vCPU, and production capped the fleet at 15 boxes with 2 warm spares. Both now get a full vCPU (memory stays 2 GiB), and the fleet can run 24 boxes with 3 warm spares. Patches should feel quicker, and more companies can be open at once before anyone waits for a box. 24 is what the account's current 30-vCPU Fargate quota allows at a full vCPU each; the budget goes to 30 once the quota is raised.
Look at
The sizes and the fleet limits in
apps/infra/src/AppStack.ts: exec and host task definitions go512→1024CPU units, and the hosts'PATCHY_LIMITS_JSONgoes{"execution.fleet.budget":15}→{"execution.fleet.budget":24,"execution.pool.spares":3}. A new infra case pins them. It fails against main's stack and passes on this branch:execution.task.cpuandexecution.task.memorystay, but inert and truthful. Nothing reads them: the ECS provider sends no size override, so the exec task definition sets every box's size. Their defaults now match it (1 vCPU, 2 GiB), and their measure says they aren't read and are kept so existing configuration still loads.docs/limits.mdsays where the size comes from. APATCHY_LIMITS_JSONnaming either id still loads, and stored override rows can still be read and removed. Removing the ids is a separate change that needs a deprecation path. The limits docs and skill snapshots are regenerated.The Fargate vCPU quota in
docs/OPERATIONS.md› Production. The account's Fargate On-Demand vCPU quota must cover 24 boxes + 4 hosts mid-deploy + the promote task, which is 29 vCPUs (it was 10), inside the current 30. Fargate refuses launches past the quota, so raising the budget to 30 needs the quota raised first.Freeing budget for a promotion, a new runbook in OPERATIONS.md › Rolling back. Housekeeping never trims the current revision's surplus spares. So a rollback to an older release (budget 15, floor 2) can stall forever with no company bound once this release holds 14 or more spares. Waiting and re-running don't help. The runbook has two statements for the platform database:
stops:max(0, live + max(0, floor − staged spares and starting) − budget).liveis everystarting,spareandboundtask of either revision, so a fleet already over the staged budget is covered;stoppingtasks are already leaving, so recounting right after a fence is correct.fleet.ts,drainTask). It sets the current revision's newestsparerows tostoppingwithFOR UPDATE SKIP LOCKED, so it never takes a row a claim holds, and a claim never takes a row it holds. Housekeeping's reconcile stops everystoppingtask through ECS on its next pass, so the operator never calls ECS. That path has existed since the fleet landed (feat(execution): manage company task fleets #438), so every release production could roll back to has it.If
stopsis more than the eligible spares, the runbook says the rest must come from bound companies going idle, and to count again each round.A throwaway probe on this head ran both statements verbatim (placeholders filled) with the real controller and store, disposable Postgres and the memory provider:
This PR adds no controller test for it, because
packages/executionbelongs to another lane this round. The probe is the reproduction.Docs that followed: OPERATIONS.md (promotion now needs three ready spares within 24), ADR-0012's production topology and hosting decisions 1–2, product.md's box size and cost promise (about $36 a month for an always-on box instead of $21, with the per-call figures scaled the same way), and a
packages/servingcomment that said "half a vCPU". ADR-0012's spike measurements still say half a vCPU on purpose: they record what was measured. The spike script keeps its own 512.How it was verified
pnpm --filter @patchy/infra exec vitest run: red on main's stack, green here (above). The security-group snapshot doesn't cover task sizes, so it is unchanged.packages/limitsandapps/infratests: 6 files, 32 tests pass. A probe loads{"execution.task.cpu":0.5}and{"execution.task.memory":2147483648}on this head without error, as on main.pnpm check: format, lint, typecheck and synth pass. The offline tests fail locally in thepackages/patchyCLI suites andLocalTaskProvider. That's strayGET /requests from another process on the shared machine reaching the tests' fake servers on random localhost ports (expected { method: 'GET', url: '/' } to match object { url: '/api/me' }). A different set fails on every run, andSdkApi.test.ts's two 5-second timeouts pass when run alone (21/21). CI is the clean run.Release impact
Infrastructure sizing and production's fleet limits, which fit the account's current Fargate vCPU quota, so nothing is needed before deploying. No API, CLI, schema or configuration-format change: every limit id that loaded before still loads, and stored overrides stay readable. The deployment configuration's revision hash changes because
execution.task.cpu's default moved from 0.5 to 1. It changes whenever a resolved value does, and nothing reads that value.Rollback line for the deploy: if this release misbehaves, roll back to the live commit. If the rollback's promote step times out short of two older spares, follow OPERATIONS.md › Freeing budget for a promotion: count, fence
stopsof this release's newest spares with the controller's own fence, recount until the older revision has its two spares, then re-run the run. If there aren't enough spares to fence, the rest of the room comes from bound companies going idle.Made by Claude Opus 5.5 via Claude Code; reviewed with GPT-6.1-Sol.