Skip to content

Don't include TMathBase.h in TString.h #19591

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 9, 2025

Conversation

guitargeek
Copy link
Contributor

@guitargeek guitargeek commented Aug 9, 2025

The TString header only uses TMath functions that are readily available in the standard library.

The TMathBase.h header is quite big, and avoiding to include it reduces the overall cold-ccache compile time of the full ROOT project (excluding LLVM/Clang) with all default features by about 2 % on my machine, namely from 870 s to 855 s on average (I repeated the measurement several times, they are reproducible to a second).

In the places there the TMath functions were used but only indirectly included via TString.h inclusion, the commit suggests to use the <cmath> functions instead.

@guitargeek guitargeek requested a review from agheata as a code owner August 9, 2025 00:23
@guitargeek guitargeek force-pushed the tstring_tmathbase branch 2 times, most recently from 92e4877 to 17330f8 Compare August 9, 2025 00:49
@guitargeek guitargeek requested a review from linev as a code owner August 9, 2025 00:49
@guitargeek guitargeek force-pushed the tstring_tmathbase branch 2 times, most recently from 8756196 to af18310 Compare August 9, 2025 01:13
Copy link

github-actions bot commented Aug 9, 2025

Test Results

    21 files      21 suites   3d 10h 46m 11s ⏱️
 3 250 tests  3 247 ✅ 0 💤 3 ❌
66 537 runs  66 530 ✅ 0 💤 7 ❌

For more details on these failures, see this check.

Results for commit 27c4e9a.

♻️ This comment has been updated with latest results.

@guitargeek guitargeek force-pushed the tstring_tmathbase branch 5 times, most recently from bbf141a to c3e8799 Compare August 9, 2025 12:09
Copy link
Member

@dpiparo dpiparo left a comment

Choose a reason for hiding this comment

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

Thanks for this refactoring!
Minor observation for the commit message: "In the places there the TMath functions" --> "In the places where the TMath functions"?

@dpiparo
Copy link
Member

dpiparo commented Aug 9, 2025

Not specific to this PR, but more in general: can an automated way be envisaged to spot similar opportunities for improving build time? Also because in ROOT buildtime and runtime, thanks to C++ interpretation, have a very much blurred borders...

@guitargeek
Copy link
Contributor Author

Not specific to this PR, but more in general: can an automated way be envisaged to spot similar opportunities for improving build time? Also because in ROOT buildtime and runtime, thanks to C++ interpretation, have a very much blurred borders...

That's a good question. I don't know how to automatize this, but I have manually identified a few spots that I might address later.

By the way, the motivation for this PR were RooFit compile times in particular. RooFit is a pretty huge codebase inside ROOT, and compile times were creeping up gradually. Also because it has so many test binaries...

I'll try to get this under control gradually, but changes should also not be too aggressive. Users might also rely on these indirect inclusions and get annoyed when the code doesn't compile anymore. The removal of TMathBase.h from TString.h is already quite the big change in that sense. In one release cycle we should probably not do much more than that.

@guitargeek guitargeek force-pushed the tstring_tmathbase branch 3 times, most recently from 3a25c19 to aa6820f Compare August 9, 2025 15:19
@dpiparo
Copy link
Member

dpiparo commented Aug 9, 2025

Given the magnitude of the change, does it make sense to already add some wording to the RNs?

The TString header only uses `TMath` functions that are readily
available in the standard library.

The `TMathBase.h` header is quite big, and avoiding to include it
reduces the overall cold-ccache compile time of the full ROOT project
with all default features by about 2 % on my machine, namely from 870 s
to 855 s on average.

In the places where the `TMath` functions were used but only indirectly
included via `TString.h` inclusion, the commit suggests to use the
`<cmath>` functions instead.
@guitargeek guitargeek merged commit 9bd7729 into root-project:master Aug 9, 2025
20 of 26 checks passed
@guitargeek guitargeek deleted the tstring_tmathbase branch August 9, 2025 23:57
guitargeek added a commit to guitargeek/HiggsAnalysis-CombinedLimit that referenced this pull request Aug 11, 2025
This fixes compilation failure after the following ROOT PR:

  * root-project/root#19591
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.

2 participants