Skip to content

precheck: about 3x faster (parallel unit tests and example loads, no fixed sleeps, staged-file skips) - #2521

Merged
sbryngelson merged 2 commits into
MFlowCode:masterfrom
sbryngelson:precheck-faster
Nov 26, 2026
Merged

sbryngelson merged 2 commits into
MFlowCode:masterfrom
sbryngelson:precheck-faster

Conversation

@sbryngelson

@sbryngelson sbryngelson commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Makes ./mfc.sh precheck, and so the pre-commit hook, about three times as fast.

Change Why
monitor_slurm_job.sh: the two sleep 2 (output not yet visible; letting tail flush) use MFC_MONITOR_POLL_SECONDS The tests set it to 0, but these two sleeps ignored it: ~2 s in each of ~25 tests, 47 s for test_monitor_exit_codes.py alone. In CI the waits go from 2 s to the 5 s poll interval
./mfc.sh validate with several cases loads them in a thread pool (up to 16) Each load runs the case file in its own interpreter (~0.5 s, 1-2 s for Cantera cases); the checks themselves take 0.1 s in all
./mfc.sh lint runs pytest with pytest-xdist (-n auto --maxprocesses=16; new dependency in pyproject.toml) 16 workers: ~58 s -> ~20 s; more do not help. CI's lint gate gets this too
The doc reference check runs in the background like the other checks It ran in the foreground and delayed the launch of example validation
The pre-commit hook passes precheck --staged Nothing staged under examples/ or toolchain/: example validation is skipped. Only docs/ staged: the unit tests are skipped (they also read src/ and examples/, so a source commit still runs them). A plain ./mfc.sh precheck and CI run everything

1. Does it solve the problem?

Measured on a Frontier login node (shared, so ±a few seconds).

Quantity master this PR
./mfc.sh precheck 148 s 45 s
pre-commit, a src/ change 148 s 40 s
pre-commit, a docs/ change 148 s 24 s
toolchain unit tests (precheck's skips) 110 s ~20 s
./mfc.sh validate examples/*/case.py 54 s 22 s

2. Does it create another one?

Check Result
Tests ./mfc.sh precheck passes; 977 unit tests pass, three times in a row under xdist
Validate output Same lines and verdict as master for all 233 examples (26 with constraint issues, same list and order); only two case files' own stderr prints land in a different place
Failures A case that exits non-zero and a missing file are still reported, exit 1
Golden files changed 0
Not tested Precheck on macOS. The changed pyproject.toml makes each checkout reinstall its venv once

3. Is it slower?

No: CI-script and toolchain only, no change to src/ or build flags. In CI, a monitored job's log ends ~3 s later.

…in parallel

monitor_slurm_job.sh had two hardcoded 2 s sleeps that ignored MFC_MONITOR_POLL_SECONDS,
which the tests set to 0; they cost ~45 s of the toolchain unit tests. Example validation
now runs the case files (one interpreter each) side by side.
@sbryngelson
sbryngelson requested a review from a team as a code owner November 26, 2026 22:14
@sbryngelson
sbryngelson requested review from wilfonba and removed request for a team November 26, 2026 22:14
@github-actions

Copy link
Copy Markdown

Claude Code Review

Head SHA: f862c58

No review was produced. Claude ran but wrote no review (Claude step: failure). Run and transcript: https://github.com/MFlowCode/MFC/actions/runs/45903519917

… files cannot affect

pytest-xdist runs the toolchain unit tests on up to 16 workers (~58 s -> ~20 s), in CI's
lint as well. The doc reference check now runs in the background with the others instead
of delaying them. The pre-commit hook passes --staged: a commit that stages nothing under
examples/ or toolchain/ skips example validation, and a docs-only commit skips the unit
tests (they read src/ and examples/ too). A plain ./mfc.sh precheck and CI run everything.
@sbryngelson sbryngelson changed the title precheck: drop fixed sleeps in the monitor tests, load example cases in parallel precheck: about 3x faster (parallel unit tests and example loads, no fixed sleeps, staged-file skips) Nov 26, 2026
@sbryngelson
sbryngelson merged commit fa03a13 into MFlowCode:master Nov 26, 2026
25 of 48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant