Hello,
I am seeing that the TFile::Close function takes a long time when closing a TFile with many histograms. The TFile::Write function, which I call first, finishes within a second.
My workflow consists of running over an ntuple once and making several versions of the same histogram for events passing different selections (ie: changing pT cuts, different b-tagging working points). The output is stored in a ROOT file with the following structure:
selection1/histogram1
selection1/histogram2
selection2/histogram1
selection2/histogram2
selection3/histogram1
selection3/histogram2
...
It allows me to quickly compare histograms between alternate selections to understand their effect.
I would like to understand why the close operation is taking so long. I am increasing the number of selections (testing different b-tagging working points) and I am seeing the closing of the TFile take hours.
I’ve attached an example demonstrating the problem. It creates 200 directories (my selections also include binning in different variables, which is why this number is so large) with 200 histograms each. The result is one second to TFile::Write and over a minute to TFile::Close. If I double the number of directories, the closing takes 6 minutes.
closeFileTest.cpp (925 Bytes)
The example code can be run with can be run with
g++ closeFileTest.cpp -o closeFileTest
$(root-config --cflags --libs )
./closeFileTest