Repository navigation
perf(check): run OutputTypesValid on the blocking pool - #4004
bryan-minimal wants to merge 1 commit into
Conversation
OutputTypesValid walked every output glob and opened and ELF-parsed each matched file inside one poll of the thread that drives the check stream. Cold, that is about 0.43 ms per output file, and on prod (2026-12-03, pkgs#1837, first sweep after boot) OutputTypesValid was checker_top for 483 s of the 568 s of polling-thread time in a 310 s checks phase. Like OutputsFreeOfDetbuild, copy what the walk needs (outputs in declaration order, target arch, spec hash, caches, cancel token) under the graph guard, drop the guard, and run the walk through poll_timing::spawn_blocking with the check_package span entered. Verdicts, messages and their order are unchanged; the time now shows under the span's offloaded field instead of checkers. The walk checks for cancellation per file, as MissingRuntimeDeps does. Adds a test that a malformed binary output fails, names the file, and that a measured check counts the walk as offloaded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
Approved: no findings at Nothing to do. Clobber: none seen. |
There was a problem hiding this comment.
Moving OutputTypesValid's glob walk and ELF parsing onto poll_timing::spawn_blocking follows the OutputsFreeOfDetbuild/DetbuildScan pattern correctly. The scan copies the outputs, arch, spec hash and caches under the guard and drops the guard before the walk. The verdicts and messages are unchanged. Errors are stringified exactly as check_package_measured already does, and ctx.bail_if_cancelled() there still returns Error::Cancelled after the join. The offloaded timing is attributed through the OFFLOADED task-local that poll_timed sets, and the new test checks it. CI is green. One medium finding: the per-file cancellation added to the walk has no test (inline).
Generated by Claude Code
| .match_files_for_glob(cached_build.path(), glob)? | ||
| .iter() | ||
| { | ||
| crate::bail_if_cancelled(&self.cancel)?; |
There was a problem hiding this comment.
Medium: the cancellation points this PR adds to OutputTypesValid (here, and before cache.read_dir at line 94) are new behaviour that no test exercises. Before this change the walk had no cancellation point; now a token that fires mid-walk makes OutputTypesScan::verdict return Err(Error::Cancelled) instead of finishing. The existing run_checks_bails_on_cancelled_token test (lib.rs) cancels before any checker runs, so it is stopped at the semaphore select! in package_check_futures and never reaches this code. The new output_types_valid_fails_a_malformed_binary_off_the_polling_thread test never cancels. If a later edit drops this check, or moves it so that a cancelled walk returns Ok(result) with a Pass verdict after reading only some files, nothing fails.
Suggested fix: add a test modelled on no_detbuild_a_cancelled_read_is_never_clean. Build an OutputTypesScan directly over a staged build, cancel its token, call verdict, and assert matches!(r, Err(Error::Cancelled)), never Ok(..) with a Pass verdict.
Generated by Claude Code
Why
On prod (2026-12-03, minimal 16cc8a9, the first sweep after a res-server boot, pkgs#1837), the checks phase took 310 s. Polling-thread time was 568 s across 1155
check_packagespans, andchecker_top=OutputTypesValidaccounted for 483 s of it (85%), e.g.checkers="OutputTypesValid=47/47,...". OutputTypesValid ran its glob walk and opened and ELF-parsed each matched file inline, inside one poll of the thread that drives the whole check stream. Cold, that is about 0.43 ms per output file, and the walk blocked every in-flight package's checkers while it ran.MissingRuntimeDepsandOutputsFreeOfDetbuildalready run on the blocking pool.What
crates/check/src/outputs.rs: OutputTypesValid follows theOutputsFreeOfDetbuild/DetbuildScanpattern. Under the graph guard it copies what the walk needs into a newOutputTypesScan: the outputs in declaration order, the target arch, the spec hash, the cache, the check cache and the cancel token. It then drops the guard and runsOutputTypesScan::verdictthroughpoll_timing::spawn_blockingwith thecheck_packagespan entered. The walk body is unchanged apart from where it reads its inputs, so verdicts, messages and their order stay the same. It now checks for cancellation per file, asMissingRuntimeDepsdoes, since a blocking task can't be interrupted.offloadedfield (OutputTypesValid=wall/cpu) instead ofcheckers.output_types_valid_fails_a_malformed_binary_off_the_polling_thread: a non-ELF, non-script binary output fails and the error names the file, a script beside it passes, and a measured check (poll_timed(true, ..)) counts the walk as offloaded work.lib.rsandpoll_timing.rsnow list OutputTypesValid among the offloaded checkers.Prior attempts
gh pr list --searchfor OutputTypesValid, offload and spawn_blocking, andgit log -S/--greponcrates/check, found no earlier attempt to offload OutputTypesValid and no revert of an offloaded checker.Expected effect
On a cold sweep, the per-file I/O moves off the single polling thread and runs in parallel on up to 20 permits. The checks phase should drop toward the warm level, and
checker_topshould stop being OutputTypesValid.🤖 Generated with Claude Code
Summary by CodeRabbit