Histogram writing too slow with "Overwrite"


ROOT Version: 6.24/02
Platform: Linux/Fedora 34
Compiler: gcc version 11.3.1 20220421


Hello,

I have a std::vector<ROOT::RDF::RResultPtr<TH1D>> type function which returns histograms as histosR. I am trying to write those histograms to a file using:

  1. fop->WriteTObject(histosR[i].GetPtr());

This works fast. But, the resulting file contains histograms from different cycles. This is unwanted. Therefore, I used second method.

  1. fop->WriteTObject(histosR[i].GetPtr(),"","Overwrite");

But, this takes considerably longer (22 seconds) when the code is executed the second time (compared to 1.6 seconds the first time), as shown below.

root [0] .L Tree2Histo_rdf.C++
Info in <TUnixSystem::ACLiC>: creating shared library /home/..../Downloads/./Tree2Histo_rdf_C.so
root [1] Tree2Histo_rdf("run169.root", "f169_170_RH.root")
Number of branches in the tree : 	385
Number of events to be processed: 	30000
10000 : events processed 
20000 : events processed 
30000 : events processed 

Elapsed time : 00h:00m:1.65s 

root [2] Tree2Histo_rdf("run170.root", "f169_170_RH.root")
Number of branches in the tree : 	385
Number of events to be processed: 	30000
10000 : events processed 
20000 : events processed 
30000 : events processed 

Elapsed time : 00h:00m:21.99s

Why adding "Overwrite" option to WriteTObject results in so much increased time of execution?

Regards,

Ajay

Hi,

6.24 is a very old version of ROOT.
How does the timing look on 6.30? It is unlikely that 6.24 will be patched.
Also, perhaps a procedural question: why would you overwrite into one entity in the files different histograms you collected in a vector?

Cheers,
D

Hi @Danilo

I tried with 6.28/10 and also with 6.30/02 and there is no improvement in the performance.

I am opening an output ROOT file in UPDATE mode. Then I collect events from different input files and write them to histograms with their corresponding branchnames as follows:

for(int i = 0; i < nBranches; i++){ 
                fop->WriteTObject(histosR[i].GetPtr(),"","Overwrite");
                //fop->WriteTObject(histosR[i].GetPtr());
        }

Sorry, maybe this wasn’t clear enough in the first post.

These are the raw reference histograms from which calibration parameters will be obtained for further analysis. It is not desirable to have same histogram from various cycles.

NOTE: I have disabled ROOT::EnableImplicitMT(); and analyzing only 30000 events with df.Range(30000).

Regards,

Ajay

Hi Ajay,

Could you provide a minimal reproducer for us to identify what is the cause and then fix the issue, if any?

Thanks a lot in advance.

Cheers,
Danilo

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.