A Fast Parallel Resume Scan for Map Runs
Classify every already-done unit at once, up front, instead of two slow sequential sweeps.
Gantry can fan a single job out across thousands of independent units — a map run. If such a run is interrupted and restarted, it has to work out which units already finished so it can skip them and build only the rest. Gantry never trusts a saved flag for this: it re-checks each unit against the files on disk every time, so a unit counts as done only when its output is really present and passes its own test.
The trouble was how that check was performed. On a large resume it spawned a separate subprocess for every unit, one after another, and it ran the entire sweep twice — once quietly to prime an internal counter, then again as the units streamed through the worker pool. For a run of a few thousand units that meant a long stretch where the progress counters barely moved, broken by frozen pauses, plus a "still working" indicator that flickered on for units that did no work at all.
This job replaced all of that with one check that runs every unit's test concurrently, across a fixed band of threads, before the pool starts. Already-done units are reported finished in a single quick burst, and the pool receives only the genuine remainder. A resume that used to crawl now reaches its baseline in well under a second.
Build
The work was cut into a self-contained parallel classifier, its integration into the resume driver, and a front-end pass — an order that let the foundation be checked against the old sequential result before the delicate checkpoint-accounting work relied on it.
The decomposition put the pure computation first. The opening piece is a classifier that runs each unit's skip-test concurrently and returns a per-unit verdict, built and tested inside the gate module with nothing in the driver or the front-ends changed. Because the old sequential sweep still existed, that piece could ship with its own oracle: a parity test asserting the parallel count equals the previous count for the same fixtures. The foundation arrived with a way to prove itself correct.
The second piece is where the difficulty actually lived — folding the pass into the driver. The visible part, handing the pool only the unfinished units, is straightforward. The load-bearing subtlety is the checkpoint counter. Today the skipped units re-stream through the pool and each one advances the checkpoint's completed count; remove them and that count starts short, so its cadence windows fire late or never. The brief calls this out by name and pins it with a test requiring the set of windows that fire on a resume to be identical to before. That boundary carried the real weight, and it held because the classifier beneath it already had a parity check standing behind every verdict.
The last piece was deliberately lowest-risk: confirm the three rendering surfaces handle a unit going straight to finished with no start event, and keep the live in-flight count at zero across the burst.
The run stayed green from end to end — no gate returned a sprint, no review redrew the remaining work. The reading is not that the task was easy but that the cut dissolved its hardest part ahead of time: the one sprint that had to reconcile two counters at once was sequenced after the function it leaned on was already grounded against the behaviour it was replacing.
Feature
Resume done-detection is now a single width-independent parallel scan in the map gate module that seeds the checkpoint baseline and emits already-done units straight to Skipped; the design still stands at HEAD, with the older whole-set counter folded into the same code path.
Before this job, deciding what a resume could skip was a subprocess-per-unit walk performed one at a time, run twice over, with the skipped units pushed through the worker pool so they briefly showed as in flight. None of that survives in the tree today.
The map gate module holds a `classify` function that fans each unit's skip-test over a bounded band of threads sized to the host's available parallelism and capped at a ceiling — its width set independently of the operator's `--jobs`, because the tests are pure reads and safe to run together whatever the build concurrency. It returns a result per unit in enumerated order, and a test that cannot even be spawned comes back as an error the driver sends through its ordinary per-unit failure path rather than treating as a quiet skip.
The driver runs that pass once. It splits the results into already-done, real-work, and error units; seeds the checkpoint baseline from the done count; emits each done unit's finished event directly with no preceding start; and admits only the remainder to the pool. The rendering surfaces were confirmed to draw that direct terminal transition with the in-flight count held at zero.
Going and looking confirms it is all still there. The merged-count summary path, once a second sequential sweep, now runs through the same classifier, so there is a single implementation of done-detection rather than two. The single-unit predicate is kept as the documented resume-safety invariant, marked as having no caller outside tests now that the whole-set count routes through the parallel path. Most of the lines the job introduced remain present, and nothing since has folded the capability into a larger design.