Public: anyone can read this; the crew can change it.
Every environment is dark for a minute after a restart: a boot deploy spends 59s before the app is even started #514
Restarts now bring every app's production back before any preview, and each deploy's log says where its time went. The underlying slowness on production restarts is not fixed yet: this change attributes it rather than removing it.
stopped closed without shipping deploy 9818e4f
Restarts now bring every app's production back before any preview, and each deploy's log says where its time went. The underlying slowness on production restarts is not fixed yet: this change attributes it rather than removing it.
This revision merges main. The only conflict was the test list in forge.json: it keeps test/web-apps.test.ts from main and adds test/apps-boot.test.ts from this branch. main had also changed src/apps/runtime.ts, and git merged it without conflicts. After the merge, type check is clean and the full check passes, 623 tests.
What production shows today (from the forge's run records): boot deploys take 12–22s from created to serving, and merge deploys take 1–5s. The 59s in the issue was from when every preview deployed at boot. Previews now come back asleep, so only production redeploys. The slow case is now a warm start: run 01m3ywep had no checkout at all and still took 21.8s, with the app's first output arriving 21.4s after the run was created. So it isn't a cold checkout or contention on the git directory, and with one deploy there's no queue to wait in.
What changed
- Timing in the log (
src/apps/timing.ts,runtime.ts,process.ts): before the process starts, the deploy writes onetiming:line splitting the time into waiting for a turn, reading the manifest, checkout, data and setup. After the app answers, a second line says how long the process took and when it first printed anything. Both web log readers treat these as forge lines. - Production first (
AppsRuntime.start): a restart now brings up every app's production, then every app's previews. Before, it went app by app, so app B's production could wait behind app A's preview. The production pass also skips the per-pull branch lookups it never used. - The gate (
src/git/env.ts): a waiter can ask to gofirst, and production deploys do. A production deploy that arrives while previews are waiting gets the next turn. Ordinary waiters are still strictly first-come, first-served.
What I chose not to do
- I didn't change
FORGE_APPS_CONCURRENCYor release the gate's slot earlier, because the measured cost isn't a queue. So there's no test that N environments take less than N× one environment's time. - I didn't change the crew, the release workflow or the chart. If the next restart's
timing:lines put the time in the process itself, the likely cause is the parent forge's own boot competing for CPU. That would be a separate, measured issue.
Before/after: a local restart of this repo running as an app took 1.2s: 0.1s of forge steps, first output at 0.8s, answered at 1.1s. That doesn't reproduce production's 12–22s. The after number from a real restart will be in the first boot log once this merges.
Tests: test/apps-boot.test.ts restarts two apps, each with an open preview, with one deploy at a time. It asserts both productions are serving before either preview and that both timing: lines appear. With the old boot loop it fails. A new gate test in test/agents.test.ts covers the jump-the-queue order. Two tests outside the check fail the same way on unchanged main on this machine:
test/agents.test.ts, the fifty-pushes test: git authentication is refused in this sandbox.test/fork-flow.test.ts: its setup times out after 5s when run on its own here. It passed in the full check.
To try it: restart the forge, open the production boot run's log, and read the two timing: lines.
🤖 Generated with Claude Code
Restarts now bring every app's production back before any preview, and each deploy's log says where its time went. The underlying slowness on production restarts is not fixed yet: this change attributes it rather than removing it.
What production shows today (from the forge's run records): boot deploys take 12–22s from created to serving, and merge deploys take 1–5s. The 59s in the issue was from when every preview deployed at boot. Previews now come back asleep, so only production redeploys. The slow case is now a warm start: run
01m3ywephad no checkout at all and still took 21.8s, with the app's first output arriving 21.4s after the run was created. So it isn't a cold checkout or contention on the git directory, and with one deploy there's no queue to wait in.What changed
src/apps/timing.ts,runtime.ts,process.ts): before the process starts, the deploy writes onetiming:line splitting the time into waiting for a turn, reading the manifest, checkout, data and setup. After the app answers, a second line says how long the process took and when it first printed anything. Both web log readers treat these as forge lines.AppsRuntime.start): a restart now brings up every app's production, then every app's previews. Before, it went app by app, so app B's production could wait behind app A's preview. The production pass also skips the per-pull branch lookups it never used.src/git/env.ts): a waiter can ask to gofirst, and production deploys do. A production deploy that arrives while previews are waiting gets the next turn. Ordinary waiters are still strictly first-come, first-served.What I chose not to do
FORGE_APPS_CONCURRENCYor release the gate's slot earlier, because the measured cost isn't a queue. So there's no test that N environments take less than N× one environment's time.timing:lines put the time in the process itself, the likely cause is the parent forge's own boot competing for CPU. That would be a separate, measured issue.Before/after: a local restart of this repo running as an app took 1.2s: 0.1s of forge steps, first output at 0.8s, answered at 1.1s. That doesn't reproduce production's 12–22s. The after number from a real restart will be in the first boot log once this merges.
Tests:
test/apps-boot.test.ts(added toforge.json's check) restarts two apps, each with an open preview, with one deploy at a time. It asserts both productions are serving before either preview and that bothtiming:lines appear. With the old boot loop it fails. A new gate test intest/agents.test.tscovers the jump-the-queue order. Type check is clean. In the full check, 597 of 598 tests passed. The one failure, intest/fork-flow.test.ts, also fails on unchangedmainon this machine (a 5s setup timeout). So does the fifty-pushes test intest/agents.test.ts(git authentication refused in this sandbox).To try it: restart the forge, open the production boot run's log, and read the two
timing:lines.🤖 Generated with Claude Code
Closes #296