Repository navigation
[PWGDQ] HistogramManager: resolve each class's histograms once, not on every fill - #18971
Conversation
|
O2 linter results: ❌ 0 errors, |
|
Error while checking build/O2Physics/code-check for 7d18ac0 at 2026-11-28 15:21: Full log here. |
axti98
left a comment
There was a problem hiding this comment.
Hi Giulio, thanks a lot for this change, this is a very nice improvement!
In principal I am fine with this implementation, I just have a question on the architecture: You store the histograms in the a std::vector where the histogram is a TObject*. Later you downcast each entry via a static_cast. This is for sure a possible solution, but have you considered whether one could cache the already casted pointers? Then we could avoid the not-so-fancy static_casts.
| // | ||
| // the histograms of a class, cast and paired with their variables on the first fill of the class | ||
| // | ||
| if (auto it = fHistsToFill.find(std::string_view(className)); it != fHistsToFill.end()) { |
There was a problem hiding this comment.
Add header for string_view in HistogramManager.cxx
…n every fill FillHistClass looked up the class's list by name, then walked it with a TIter and dynamic_cast every histogram to find its type, on every call. In the dielectron trains 814771-3 and 814961-3 this was 35-39% of the CPU. The histograms of a class, the variables each one is filled with and its dimension are now resolved on the first fill of the class and kept; adding a histogram or changing the main list clears the cache. The fill itself is unchanged. The 814771 workflow on one of its input files (2 GB, arm64 Mac): 401 s -> 159 s user CPU, the same peak memory, and an AnalysisResults.root with all 1803 TH1/TProfile and 63 THn identical bin by bin (contents, errors, entries, statistics).
|
@axti98 thank you. I have pushed a new version with most of your comments addressed. One could provide an update which uses and Moreover, I would consider moving everything to the Framework provided histogram registry, if you are open to large changes. |
|
Okay if it would be too complex we can leave it like this for now. |
FillHistClass looked up the class's list by name, then walked it with a
TIter and dynamic_cast every histogram to find its type, on every call. In
the dielectron trains 814771-3 and 814961-3 this was 35-39% of the CPU.
The histograms of a class, the variables each one is filled with and its
dimension are now resolved on the first fill of the class and kept; adding
a histogram or changing the main list clears the cache. The fill itself is
unchanged.
The 814771 workflow on one of its input files (2 GB, arm64 Mac):
401 s -> 159 s user CPU, the same peak memory, and an AnalysisResults.root
with all 1803 TH1/TProfile and 63 THn identical bin by bin (contents,
errors, entries, statistics).