Skip to content

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 serially, reducing the CTest throughput.

Here, by using a RESOURCE_LOCK in ctest, Ninja compilations are not run from multiple tests at the same time. They may, however, run in parallel with pre-compiled tests.

The following is now outdated:

Note that this might break if the main build tree is outdated. That's because ninja might rebuild dictionaries or libraries while these are in use by pre-compiled tests. This can be prevented by:

Bad Good
touch core/... touch core/...
ctest -jN ninja && ctest -jN

The above problem is fixed by adding another test that updates the build tree, running in complete isolation. This is equivalent to running ninja && ctest, only that the ninja invocation is part of the ctest run if tests that require compilation are part of the test suite.

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
Copy link

github-actions bot commented Aug 21, 2025

Test Results

    20 files      20 suites   3d 19h 41m 18s ⏱️
 3 656 tests  3 654 ✅ 0 💤 2 ❌
71 438 runs  71 431 ✅ 5 💤 2 ❌

For more details on these failures, see this check.

Results for commit c166439.

♻️ 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
@@ -2714,7 +2714,7 @@ macro(ROOTTEST_GENERATE_EXECUTABLE executable)
endif()

if(CMAKE_GENERATOR MATCHES Ninja AND NOT MSVC)
set_property(TEST ${GENERATE_EXECUTABLE_TEST} PROPERTY RUN_SERIAL true)
set_property(TEST ${GENERATE_EXECUTABLE_TEST} PROPERTY RESOURCE_LOCK NINJA_COMPILATION)
Copy link
Member

Choose a reason for hiding this comment

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

Important note: This changes works IF AND ONLY IF the ninja compilation does not induce spurious rebuild of the core libraries .. which unfortunately does happens from time to time (for example on Windows or any other machine with 'low' timestamp granularity where ninja gets confused and rebuild things ... things may or may not be better after we recently removed a large swat of spurious updates/rebuild when doing 2 consecutive builds)

Copy link
Member Author

Choose a reason for hiding this comment

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

As can be seen from the line above, Windows was never part of this adventure, so I guess that we don't need to worry about this in this context.

Regarding rebuilds, I'm testing at the moment a fix for the outdated build tree problem mentioned in the PR description. Will ping once done.

@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 September 1, 2025 15:54
…ests.

In roottest, some targets are added to the Ninja build graph. These are
compiled as part of the test suite, but this would create race
conditions when many builds are started in parallel. Therefore, all
these builds were flagged with RUN_SERIAL, significantly reducing the
parallelism of roottest.
Now, the tests that compile have "RESOURCE_LOCK NINJA_COMPILATION", so
only a single test that compiles exectables can run, but it can run in
parallel with tests that don't compile.
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 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants