feat(nwsync): emit blobs in parallel with a bounded worker pool (#79)
ci / ci (pull_request) Successful in 3m32s
ci / ci (pull_request) Successful in 3m32s
Emit is latency-bound, not CPU-bound. Every blob costs two serial HTTP round-trips to the zone — an existence probe, then an upload — so a hak with a few thousand resources pays a few thousand serialised latencies. A measured backfill spent 26 seconds of CPU across 9.5 minutes of wall clock, on a host with three of four cores idle and 5 GB free. Emit now hashes, compresses and stores `--jobs N` resources at once (default 16, matching DEPOT_JOBS and the transport's idle connections per host). Three properties had to survive, and each has a test: - The manifest's bytes are promised deterministic by emitterVersion, so entries is index-addressed rather than appended to: a worker owns entries[i] alone and the slice comes back in artifact order whatever order the uploads finish in. - The index is still the publication marker, so any worker's failure aborts the run before a manifest is written. Workers drain the rest of the channel instead of returning, which keeps the feeder from blocking on workers that have gone away. - Two resrefs holding identical bytes still share one blob. Serially the sink's existence check absorbed that; in parallel both workers would probe, both miss, and both upload. Claiming the sha1 in-process restores the dedupe and skips a probe round-trip as well. Peak memory is now the resources in flight rather than one resource, so the ceiling is N times the 15 MB per-resource limit and its compressed copy — bounded by a constant this package enforces itself, and still nowhere near tracking the archive. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
+10
-1
@@ -48,10 +48,19 @@ beside the artifact itself with the extension replaced, so `emit` and
|
||||
`assemble` agree on where it is without being told.
|
||||
|
||||
```
|
||||
nwsync emit [--as NAME] [--out DIR] <artifact-key> <file>
|
||||
nwsync emit [--as NAME] [--out DIR] [--jobs N] <artifact-key> <file>
|
||||
nwsync assemble --group-id N [--tlk-key KEY] [--out DIR] <artifact-key>...
|
||||
```
|
||||
|
||||
`emit` is latency-bound, not CPU-bound: every blob costs an existence probe
|
||||
plus an upload, and a measured backfill spent 26 seconds of CPU across 9.5
|
||||
minutes of wall clock. `--jobs N` (default 16) sets how many resources are in
|
||||
flight at once. The manifest is byte-identical at any value — the number of
|
||||
workers is never observable in the output. Peak memory is `N` times the
|
||||
per-resource limit of 15 MB plus its compressed copy, so raising `N` far past
|
||||
the default costs real memory for little gain: the transport keeps 16 idle
|
||||
connections per host, and past that a worker pays a fresh TLS handshake.
|
||||
|
||||
Both verbs upload by default; nothing bulky is ever written to the runner's
|
||||
disk. `--out DIR` writes a local repository tree instead, which is the
|
||||
conformance path against upstream `nwn_nwsync_write`. The zone comes from
|
||||
|
||||
Reference in New Issue
Block a user