Repository navigation
Validate in ~3 minutes, gate every output parity suite and the instruction count - #99
Merged
open-session-submodule[bot] merged 5 commits intoNov 11, 2026
Merged
Conversation
jfrolich
force-pushed
the
ci-speed-icount
branch
4 times, most recently
from
November 11, 2026 19:44
b8f4479 to
2898161
Compare
The validation workflow ran everything in one 20-minute job on one runner. Most of it was compiling: the compiler test binary, the build system test binaries and the rescript executable, each fat-LTO-linked and each built one after another. Now the build job makes one rescript executable without LTO and hands it to the compiler tests, the gating parity suites (JavaScript and diagnostics) and the diagnostic-only IR parity suites, which run on their own runners. The build system tests compile on another runner from the start. LTO does not change behaviour, and nothing ships from these builds; the Instruction count workflow builds the shipped configuration. Rust dependencies are cached with rust-cache (saved by trunk runs), which keeps only the compiled dependencies, the part a fresh checkout can reuse. The parity scripts' own tests move to the build system test job, which finishes before the parity jobs and needs no executable. Co-authored-by: Jaap Frolich <jfrolich@gmail.com> Session: https://jakes-mac-mini.tail23a77e.ts.net:8443/session/os-01a1cb83-dc2c-7699-ae5b-a6cbc18944ef Signed-off-by: Jaap Frolich <jfrolich@gmail.com>
A new workflow builds the pull request's rescript and its base's with fat LTO and one codegen unit, then counts the instructions a clean single-threaded build of tests/tests executes with each, under cachegrind (GitHub's runners expose no hardware counters). It fails when the pull request's count is more than 0.1% above the base's. Why 0.1%: four clean builds with one executable on CI varied by 0.08% (4,635.9 to 4,639.5 million instructions); the comparison takes the smallest of five runs per side. Both checkouts sit at paths of the same depth: with the checkouts at different depths, two builds of the same code differed by +0.09%, mostly in path handling. One codegen unit keeps the count from moving with how the code happens to be partitioned, which on 16 units was about 1% between equivalent builds. Both sides build the base's tests/tests, so pull requests that add tests are not measured as slower, and each uses its own embedded runtime. Trunk runs cache the executable of each commit, so a pull request usually builds only its own. An increase is accepted by a trailer `Instruction-count-increase: <why>` on one of the pull request's commits. Co-authored-by: Jaap Frolich <jfrolich@gmail.com> Session: https://jakes-mac-mini.tail23a77e.ts.net:8443/session/os-01a1cb83-dc2c-7699-ae5b-a6cbc18944ef Signed-off-by: Jaap Frolich <jfrolich@gmail.com>
The Correctness Contract in AGENTS.md names four output parity suites: JavaScript, stdlib, genType and diagnostics. CI ran only JavaScript and diagnostics, both in one job, so a pull request showed one red parity check without saying which suite failed, and runtime and genType output were not checked at all. The parity job is now a matrix with one check per suite: javascript (with the CLI output filename and marshal checks), diagnostics, stdlib and gentype. They run side by side after the build job and finish before the compiler tests, so the workflow takes no longer. The genType script always includes the Tella suite, which needs a private checkout. GENTYPE_PARITY_WITHOUT_TELLA=1 runs the two in-repo suites only and says so in the output; CI sets it. Co-authored-by: Jaap Frolich <jfrolich@gmail.com> Session: https://jakes-mac-mini.tail23a77e.ts.net:8443/session/os-01a1cb83-dc2c-7699-ae5b-a6cbc18944ef Signed-off-by: Jaap Frolich <jfrolich@gmail.com>
The diagnostic parity script ran its 2,101 cases one after another, about 4,200 compiler processes, and forked tr and cat several times per case around them: 95 s on the Mac mini, 56 s on CI. With PARITY_JOBS above 1 (the default is the number of CPUs) the case loops first queue each case's OCaml and Rust commands as one task, run the tasks PARITY_JOBS at a time with xargs, then compare the captured outputs in the original order. A case's two commands still run one after the other, and the packages and interfaces cases need are still prepared serially before any task runs. PARITY_JOBS=1 keeps the old one-case-at-a-time behaviour. Safe names, exit statuses and queued commands now use bash builtins instead of subshells and tr. Locally the suite takes 17 s instead of 95 s, with the same summary. A new test runs the compiler cases with fake compilers at PARITY_JOBS=1 and 4 and checks that both report the same failures. Co-authored-by: Jaap Frolich <jfrolich@gmail.com> Session: https://jakes-mac-mini.tail23a77e.ts.net:8443/session/os-01a1cb83-dc2c-7699-ae5b-a6cbc18944ef Signed-off-by: Jaap Frolich <jfrolich@gmail.com>
The validation workflow took about 10 minutes: a cold release build of rescript (4-5 min, since Cargo rebuilds this repository's crates after a fresh checkout whatever is cached), then the compiler tests, which also compiled their crate from scratch, and every parity job spent 40-50 s installing OPAM and building the OCaml reference compiler. Now: - Jobs run on ubuntu-24.04-arm, where the same release build took 194 s against 238 s on x64. - The release and compiler-test target directories are cached by trunk runs with rustc's incremental state, and Cargo decides freshness by file contents (-Zchecksum-freshness) rather than the checkout's mtimes, so a pull request recompiles only what it changed. - An ocaml job builds just the OCaml bsc and res_parser and caches them by the hash of the sources dune builds them from. OPAM is set up only when that cache misses; the parity jobs take the executables as an artifact. - The compiler tests compile from the start and wait for the build and ocaml jobs' artifacts only before running, and build in the dev profile: the tests run in half a second, building them is the cost. - The build job only builds and uploads; the build system tests rebuild the same release target on their own runner and save its cache, so the parity jobs do not wait for the tests or the cache upload. - The parity scripts' self-tests run in parallel in their own job, and the three diagnostic-only IR suites are a matrix like the gating ones. The Instruction count workflow stays on x64: its fat-LTO, one-unit builds took 416-456 s on Arm against about 355 s on x64. Co-authored-by: Jaap Frolich <jfrolich@gmail.com> Session: https://jakes-mac-mini.tail23a77e.ts.net:8443/session/os-01a1cb83-dc2c-7699-ae5b-a6cbc18944ef Signed-off-by: Jaap Frolich <jfrolich@gmail.com>
jfrolich
force-pushed
the
ci-speed-icount
branch
from
November 11, 2026 19:46
2898161 to
4159d91
Compare
Contributor
There was a problem hiding this comment.
Independent review of the five commits at 4159d91 (I did not write this change).
- No gate is weakened. JavaScript and diagnostics parity run the same scripts with the same flags as before; stdlib and genType parity are new gating checks. The typedtree and Lambda suites stay
continue-on-error, as the Correctness Contract describes them. - Parallel diagnostics parity. Each case's OCaml and Rust commands stay in order inside one task, packages and cached interfaces are still prepared serially before any task runs, the comparison walks the cases in the original order, and a command with no captured status falls back to running directly. Stale
.statusfiles are deleted at start-up, so a result cannot come from an earlier run. The new test checks that serial and parallel runs report the same failures, including a differing output and a timeout. GENTYPE_PARITY_WITHOUT_TELLA=1skips only the third suite and prints that it did; without the variable the script still refuses to run without that checkout.- OCaml reference cache. The key covers every
.ml,.mli,.c,.hand dune file undercompiler, which is everythingrescript_compiler_main.exeandres_cli.exeare built from. - Instruction count. Both sides build the parent's
tests/testsfrom checkouts at equal path depth, the smallest of five runs is compared, and only a realInstruction-count-increase:trailer accepts an increase. Trunk pushes report without failing.
One thing to be aware of, not blocking: the compiler tests now run in the dev profile instead of --release.
All 16 checks pass. No compiler source changes, so generated output cannot move.
open-session-submodule
Bot
merged commit Nov 11, 2026
4740a90
into
ocaml-to-rust-rewrite
16 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
CI changes for pull requests against
ocaml-to-rust-rewrite: the validation workflow drops from about 20 minutes to about 3, every output parity suite of the Correctness Contract gates a change, and a new check fails PRs that make the compiler execute more instructions.Validation workflow
It used to be one job of about 20 minutes. Most of that time went to three cold release builds with fat LTO, run one after another; every parity step then set up OPAM and built the OCaml reference compiler.
buildrescriptwithout LTO, uploaded as an artifactocamlbscandres_parser, cached by their sources; OPAM is set up only on a misscompiler-testsbuild-system-testscargo test --releasefor rewatch; saves the release cachescript-testscompiler-warningsparity (javascript)build,ocamlparity (diagnostics)build,ocamlparity (stdlib)build,ocamlparity (gentype)build,ocamlir-parity (typedtree / raw-lambda / lambda)build,ocamlubuntu-24.04-armbuilt the same release in 194 s against 238 s on x64.CARGO_UNSTABLE_CHECKSUM_FRESHNESS, the toolchain is a pinned nightly), not by the mtimes a fresh checkout sets, so a PR recompiles only what it changed.scripts/test_error_output_parity.shnow runs its casesPARITY_JOBSat a time (default: the CPU count;1keeps the old behaviour), keeping each case's OCaml and Rust commands in order and comparing in the original order. Locally 95 s → 17 s, on CI 56 s → 19 s, with the same results; a new test checks serial and parallel runs report the same failures.GENTYPE_PARITY_WITHOUT_TELLA=1, which skips only that suite and says so.Measured on this PR (caches saved by its own earlier run, as trunk runs will save them):
lambda/lam_compile.rsThe first trunk run after merging is a cold one and saves the caches.
Instruction count
A new
Instruction countworkflow fails a PR that makes the compiler execute more instructions. It builds the PR'srescriptand its base's like a release (fat LTO, one codegen unit), then counts with cachegrind the instructions of a clean single-threadedtests/testsbuild with each, five runs per side, keeping the smallest.perf: "instructions:u event is not supported").tests/tests, so a PR that adds tests is not counted as slower. Each side uses its own embedded runtime.cg_annotate --diff).Instruction-count-increase: <why>trailer to one of the PR's commits (parsed withgit interpret-trailers, so only a real trailer counts).Verification
This PR's own runs use the changed workflows: all checks pass, cold and warm.
Started by Jaap Frolich in this Assistant session