Skip to content

Speed up CTest, particularly for RDataFrame#19702

Merged
hageboeck merged 2 commits intoroot-project:masterfrom
hageboeck:fasterCTest
Oct 14, 2025
Merged

Speed up CTest, particularly for RDataFrame#19702
hageboeck merged 2 commits intoroot-project:masterfrom
hageboeck:fasterCTest

Conversation

@hageboeck
Copy link
Member

@hageboeck hageboeck commented Aug 20, 2025

Allow Ninja compilation in CTest to run in parallel with other tests

roottest Ninja targets are rebuilt as part of a ctest run. If two tests invoke Ninja, race conditions will occur.
To prevent that, ROOT used to run all tests with Ninja compilation in complete isolation, which can lead to a very long tail of tests that only keep a single core busy.

Here, the RUN_SERIAL property is removed, and a RESOURCE_LOCK is employed to ensure that only one Ninja process runs at any given time, but that process may run in parallel with pre-compiled tests. In order to ensure that there is no interference with the pre-compiled tests:

  • The build tree is refreshed using a test fixture that runs in isolation
  • And subsequent tests that invoke Ninja only build single targets

Note that this prevents users from recompiling only one single package and invoking a test that runs Ninja, while leaving the rest of the build tree outdated, since the entire build tree will be refreshed by the test fixture. I consider this use case a very niche case, though, since it is anyway very fragile because of frequent problems with outdated pcms, so it is usually best to complete the build.

Allow multi-threaded RDF tutorials to run in parallel with others

ROOT used to forbid running an MT RDF tutorial in parallel with another MT RDF tutorial. When running ctest -R dataframe -jN, this can lead to a long tail of tutorials running completely sequentially. Nevertheless, since ROOT honours ROOT_MAX_THREADS, each was only running with 4 cores.
Here, the strict RESOURCE_LOCK is removed, and CMake is just informed about the required number of CPU cores. This allows for running a few of the MT tutorials in parallel.

@hageboeck hageboeck requested a review from dpiparo August 20, 2025 15:29
@hageboeck hageboeck self-assigned this Aug 20, 2025
@github-actions
Copy link

github-actions bot commented Aug 21, 2025

Test Results

    22 files      22 suites   3d 14h 48m 59s ⏱️
 3 690 tests  3 690 ✅ 0 💤 0 ❌
79 226 runs  79 226 ✅ 0 💤 0 ❌

Results for commit 6912bc9.

♻️ This comment has been updated with latest results.

Copy link
Member

@pcanal pcanal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

@pcanal pcanal self-requested a review August 22, 2025 17:03
@guitargeek
Copy link
Contributor

For the ROOTTEST_COMPILE_MACRO, I think the simpler solution would be to not wrap the root ... macro.C command in a target, as I propose in this PR:

hageboeck and others added 2 commits October 13, 2025 14:36
In addition to correctly specifying the number of CPUs in CMake, the
tutorials were also setting a resource lock, which prevented them
from running in parallel with other RDF tutorials.
Since ROOT honours ROOT_MAX_THREADS, this resource lock can be removed.

Co-authored-by: Philippe Canal <pcanal@fnal.gov>
In roottest, targets are occasionally added to the Ninja build graph.
These may be built as part of the test suite, possibly creating race
conditions when Ninja is invoked from multiple tests. Therefore, all
these builds were flagged with RUN_SERIAL, significantly reducing the
parallelism of ctest.

Therefore:
- Add a test fixture to refresh the build tree. It is run before any
  test that invokes Ninja.
  The fixture runs in complete isolation to avoid any errors in tests
  that are started in parallel with the Ninja build.
- Add "RESOURCE_LOCK NINJA_BUILD" to all tests that invoke Ninja.
  This ensures that only one Ninja process runs at any given point. In
  conjuction with the above fixture, this ensures that the Ninja build
  only touches the test executable, while targets that are part of
  "ninja all" are unaffected. This fact allows tests that come out of
  "ninja all" to run in parallel with tests that invoke Ninja on test
  executables.
@hageboeck hageboeck merged commit f5fca06 into root-project:master Oct 14, 2025
27 checks passed
@hageboeck hageboeck deleted the fasterCTest branch October 14, 2025 07:08
@hageboeck
Copy link
Member Author

The mac14 failure happens intermittently also in master, so seemingly unrelated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clean build Ask CI to do non-incremental build on PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants