Repository navigation
Conversation
generate_test_matrix.py splits the tests of a CI run into consecutive chunks, by name, with the same number of tests each. What a test costs (building its target and running it) varies by far more than the number of tests, and tests of neighbouring names cost about the same, so the expensive ones end up in a few shards. In a Linux (Debug, all tests) run on a pull request every shard had 132 tests (120 in the last), but the slowest shard took 52 minutes and the median 26. In a Windows (Release, VS2022, C++20 Modules) run the slowest took 75 minutes and the median 12; there the slowest shard decided how long the pull request took. --split interleaved deals the targets out one by one instead. Tests of the same target (the same program run for each parcelport) stay together, so a target is still built in one shard only. The default is the existing split, and its output is the same, byte for byte, as before. Add tests for both splits. Signed-off-by: Arubik <102335860+ArubikU@users.noreply.github.com>
Add the input split, 'contiguous' or 'interleaved', and pass it to generate_test_matrix.py. The default is contiguous, which is what the workflow did so far, so no caller changes. The value goes through the environment and not into the script text, as the other inputs do, so that it can't be used to inject a command. Signed-off-by: Arubik <102335860+ArubikU@users.noreply.github.com>
Use the interleaved split in the workflow that costs the most (27 jobs, about 735 job minutes for a pull request, 79 minutes from start to end). Replaying the measured costs of one run with this split gives a slowest shard of about 31 minutes instead of 52, and about 57 minutes for the whole workflow instead of 78. The total work stays the same. This is a model, not a measurement: it spreads the build time of each shard equally over its targets. The run of this change is the measurement. The names of the checks change, from '24-runtime_configuration-serialization (132)' to '24 (132)'. Undoing this is removing the line. Signed-off-by: Arubik <102335860+ArubikU@users.noreply.github.com>
The scripts in .github/ci-scripts decide how the tests of every pull request are split over the CI jobs. Run their tests when they change: the workflow takes seconds and does not run for other changes. Signed-off-by: Arubik <102335860+ArubikU@users.noreply.github.com>
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.
Proposed Changes
Split the tests of the sharded CI workflows by interleaving their targets, not by consecutive names, so that no shard gets all the expensive tests.
generate_test_matrix.py: new option--split {contiguous,interleaved}. The default,contiguous, is the current behaviour; its output is identical byte for byte (checked on the 3,288 tests of a real run).interleaveddeals the targets out one by one; tests of the same target (the same program for each parcelport) stay together, so a target is still built in one shard only.test_generate_test_matrix.py: 15 tests of both splits.sharded-build-and-test.yml: new inputsplit, defaultcontiguous, passed to the script through the environment. No caller changes.build-and-test.yml(Linux, Debug, all tests):split: interleaved, as a pilot.ci-scripts-tests.yml: a workflow that runs those tests when.github/ci-scriptschanges (seconds).Each commit stands alone and can be dropped. Dropping the last two leaves a change that no workflow uses.
Any background context you want to provide?
The problem, measured
Head commit of a recent pull request (TheHPXProject#8240), taken from the Actions API:
Two sharded workflows decide that time. A sharded workflow builds the libraries in one job, then runs the tests in shards that each build and run their part. The pull request is as slow as
libraries + slowest shard:Every shard has the same number of tests and the cost is not the same by far. In the Linux run:
24-runtime_configuration-serialization)16-futures-algorithms)13-synchronization-local)11 of the 25 shards built nothing at all (their tests were built by the libraries job), and one of those took 38 minutes only running tests.
The cause
generate_test_matrix.pysorts the test names and cuts them in chunks ofceil(n / shards)consecutive tests:The number of tests says little about their cost, and tests of neighbouring names are alike, so the heavy ones fall into a few shards. In the Linux run the slowest shard holds 60 of the 90
segmented_algorithmstests of the whole run; in the Windows run the slowest shard (18-schedulers-segmented_algorithms) holds 56 of its 61.The change, replayed on the measured costs
I ran the real script on the test names of both runs and priced each shard with the build time and the ctest time measured in that run. The model spreads the build time of a shard equally over its targets, so it keeps the differences between shards (the cause) and ignores those inside a shard. On the current split it reproduces the observed shards with a mean error of 0.5 minutes.
The total work does not change (709 and 345 job minutes in the model).
This is a model, not a measurement. It is an upper bound: if a few single targets are very heavy it is optimistic. The run of this pull request on the Linux workflow is the measurement, see below.
What I checked
--exclude .github/workflows/exclude.targetssplit_interleaved/split_contiguouseach fail some testctest -Nreplaced by the real list, runs under bash with both values ofSPLITRUN_SERIAL(a test alone in its ctest run),TIMEOUT,WILL_FAILandENVIRONMENT: noDEPENDS,FIXTURES_*orRESOURCE_LOCKRun the tests yourself:
and compare the splits on any
ctest -Noutput:What I did not check
interleavedyet. That needs a run of the workflow on this branch.windows_release_vs2022_modules.yml,windows_release_vs2026_modules.yml) once the Linux run confirms it. Not done here.Risks and how they are contained
24-runtime_configuration-serialization (132)to24 (132). Only Codacy is a required check on master, so no rule refers to them. A person looking for "the segmented algorithms shard" now reads the log.split: interleavedinbuild-and-test.yml).How to confirm it (needs a run)
Run
Linux (Debug, all tests)on this branch and on its base withworkflow_dispatch, on the same commit, and compare:jobs),A single pair of runs says little about the noise of the runners; three each would.
Not in this pull request
Things I saw while measuring that this change does not touch. They are separate decisions and I did not want to mix them in:
Codacy Static Code Analysisis a required status check. The 150 or so CI jobs are not required, and there is no merge queue (nomerge_grouptrigger anywhere). On 2026-11-21 ten merges in a row left master red for 26 minutes: Match split credits to the ids being serialized by their gid TheHPXProject/hpx#8146 and Find the extra data of archives and futures in constant time TheHPXProject/hpx#8167 were merged one minute apart and do not compile together (post_receive_actions.cpp:28). A merge queue needs both a repository setting and required checks, which is for the maintainers.-DCMAKE_CXX_CLANG_TIDY=clang-tidy-21, so clang-tidy runs on every translation unit while building. I did not measure what it adds to the 735 job minutes of that workflow. If it is a lot, running it on the changed files only is the next thing to look at.Documentation Buildtakes 88 minutes of one job on every pull request. The single HTML (20 min) and PDF (34 min) steps could be left for master and releases, but that is 54 minutes, 1.5% of the job minutes, and it is not on the path that sets the time from start to end, so I left it alone.Checklist
Not all points below apply to all pull requests.