The following reproducer:
seems to act in a weird way, causing a drastic decrease of performance.
The idea is simple: we have a main TChain, created from a TTree "myTree" saved inside filexy.root, that has two branches (x and y) with 1800000 events.
Then we create two other TChains out of the TTrees "myTree" saved in filez.root and filez2.root, each one containing only one branch (z in the case of filez.root and z2 in the case of filez2.root).
Note that we put the names of the files in vectors because in principle we want to add all the files in the vector to the appropriate TChain.
The point is that in the loop we don't even touch branches that belong to the friend TChains, but their addition seem anyway to affect the performance of the program. You can easily check the difference between the two configuration by simply commenting out the addition of the friend TChains.
I attach the following:
- FlameGraph of the script, where a weird (in my opinion) call to TTree::RemoveFriend() can be seen (I say weird because we don't explicitly remove friends in any part of the code);
- the scripts used to create the TFiles mentioned in the script;
- a copy of the script itself.
To compile and produce the FlameGraph I did the following:
- clone the FlameGraph repository and move inside it;
- copy there the reproducer and the root files produced with the Python scripts attached;
- after compiling the reproducer and getting an executable called exe, run the following: