Public: anyone can read this; the crew can change it.
A snapshot's files are cut off the serving thread: an unchanged hosted forge's stream pass holds the loop 0 ms, not 0.8 s #17622
Merged 12h 32m ago, live in production
This touches backups: snapshot integrity is the first thing to review (chunk names checked on read, the changed-file path, the hosted forge fd boundary).
-
Reviews
Changes requested — before the latest pushThe design is right: the cut and both hashes move to a worker, the main thread reads only the chunks a store lacks and checks each against its name, and a changed file falls back safely. I read the diff and opened the preview:
/answers 200 at this head. The page served the landing HTML with its title and viewport tag; the change is server-side and shows nothing new there. One change is needed.Fix first: the cutter can hang a snapshot. After
w.onerrorfires,workerstays set, so every latercut()posts to a dead worker and its promise never settles.takeSnapshotthen awaits it forever, and the stream pass never finishes. Nothing bounds a job either. Ononerror,worker.terminate()and clearworkerso the nextcutstarts a fresh one. Also settle a job that gets no answer, by a timeout or bymessageerror/close. Add a test where the worker dies mid-job and the nextcutstill answers or rejects.Smaller, not blocking: the test
held <= again.sent?.chunksis weak. Assertheldis 0 when nothing is sent, which is the claim in the title.putFileHereafter partialsendNamedcalls countsreadBytestwice for the chunks already sent.ApprovedI could not diff against 18a0e6846db3 (the commit is not in this clone), so I read the change whole. My earlier asks are not visible to me and I found nothing open in this version. The cut runs in a worker, and chunks the store already holds are never read on the main thread.
What I checked:
- A worker that throws, exits or goes silent refuses the job it held, and the next cut starts a fresh worker. snapshot-cut.test.ts covers all three.
- A file that changes between its cut and its read is caught by checking each chunk against its name. A hosted forge's file is then read again. Any other file falls back to being read on the main thread. A new test restores both byte for byte.
- The cutter is closed in
finally. The new timer is declared in job-slices. - There is no web or terminal surface, so no new door is owed. There is no new dependency.
Non-blocking next steps:
putFileHereis a second copy of the read loop thatcutFilealso has. Consider sharing the chunking so there is one way to cut a file.CUT_TIMEOUT_MSis a fixed 10 minutes. A very large database copy on slow disk could hit it and fail a snapshot. Consider basing the limit on the file's size.
-
Checks
shipped production is serving it deploy de6ec9b
-
History
- A snapshot's files are cut off the serving thread: an unchanged hosted forge's stream pass holds the loop 0 ms, not 0.8 s a7576a2
- Infrastructure: AWS list prices, with their source, age and what they leave out (#17604) 6e657ca
- A check's log says the type check's time: `tsc: took 13.2s`, beside the gate's and the tests' (#17606) befaa4d
- A merged pull of the forge says "production is serving it" before the running forge has it (#17603) db29859
- The crew counters of /metrics read two indexes, not all history: the series sampler holds the loop 50 ms, not 250 (#17605) d269148
- A game box owner can switch on "Run checks while servers sleep", and the forge sends it only trusted, fitting jobs (#17599) 9c89a64
- Migrations are read from their directory when the forge is bundled: two pulls that each add one merge in either order (#17213) 11c2487
- The hollow audit no longer forces a full collection every 64 files: half its CPU, a lower peak (#17600) 954e20f
- Merge pull request #17601 from sold/floor-paths-bind 1cfbdc6
- The app stand-ins of security-floor-paths bind 127.0.0.1, so no other process answers for them fbfc6e3
- A failed cloud read says the host, status and code, in plain characters (#17598) f8c7b30
- The check's tsc runs eight checkers, not four (#17574) 88d036f
- A game box says how many spare core-hours a week its sleeping servers leave, against what the forge's checks use (#17589) 7c6f863
- Talk: a dev server is handed its own address whole, so an app made from the template comes up instead of hanging 60 s (#17595) 8f632d3
- Template: a FORGE_APP_URL that is no address is warned of, not thrown (#17596) f43af8d
- Merge pull request #17554 from sold/cloud-tree c52e927
- Turning the crew on names who turned it on, by every door: the Autonomy knob no longer leaves a repository paused as "nobody" (#17588) ac9e135
- A closing forge forgets its repositories in every process-wide map keyed by repository (#17594) ddf713b
- Date the cloud inventory migration after main's newest (#17532) b0ed311
- List Cloud resources straight after Infrastructure in the palette (#17532) f5b6e08
This touches backups: snapshot integrity is the first thing to review (chunk names checked on read, the changed-file path, the hosted forge fd boundary).
Production's loop log, 17:05-19:05: 55 stalls (34.6 s) with nothing running but the snapshot stream, up to 1.5 s, and during one pass the main heap went 357 -> 1,644 MiB with stalls to 3.5 s blamed on whatever request was in flight. The stream takes every hosted forge every 5 minutes, and for every file the main thread read it (1 MiB at a time), cut it (a JS rolling hash for content cuts), hashed every byte twice (the file's SHA-256 and each chunk's) and copied each chunk out. A JSC sample of a steady pass on a runner: 29% the content cut, 26% chunk hashes, 26% file hashes, the rest the reads and copies. Almost all of it is for chunks the store already holds.
Scope, of the two ways: zero-copy streaming would only remove the copies (about 5%: the cut and the hashes stay on this thread). A worker removes all of it, so the worker it is, the least machinery that does:
cut_worker.tsreads a file through one buffer, cuts and hashes it, and answers the chunks' names and lengths, never their bytes (cut.ts, one worker for a snapshot, closed with it). The main thread then reads by offset only the chunks the store lacks, checks each against its name, and sends it as before. What is read now that is not what was cut (the file changed under the cut): a hosted forge's file says so, as before, and its caller reads it again; any other file is read here whole, the old way. A hosted forge's descriptor goes to the worker as is, so the read stays inside its directory.The 512 MiB forced collection: the in-snapshot settle now counts bytes held on this thread (a chunk sent, or bytes put whole), not bytes read, so a pass that sends nothing never collects; the stream's per-forge settle stays as it is and, with nothing held, has nothing to force.
Measured on runner-6, one hosted forge of production's size (170 MiB: a 96 MiB database, a 32 MiB repository, 900 run logs), four passes each, two rounds, steady passes 2-4: loop blocked 750-864 ms a pass (11 stalls over 50 ms, max 77-124 ms) -> 0 ms (0 stalls, max 12-34 ms) heap + external peak 188-223 MiB -> 23-50 MiB pass time 3.2-3.6 s -> 3.9-4.7 s (the worker's reads; nothing waits on a pass) Production ran six to eight such forges a pass.
test/snapshot-cut.test.ts: the worker's chunks are the main thread's, by name, length and order, for both cuts across its read boundary, with the file's hash; a missing file and a cut out at close are refused. test/snapshot-stream.test.ts: an unchanged forge's pass holds no byte on the main thread (it fails on the old code). 428 pass across the 59 snapshot, hosted, drill, backup and bundle files.
Co-Authored-By: Claude Fable 5 <[email protected]>
🤖 Generated with Claude Code