xAOD::TEvent Speedup, master branch (2022.08.26.)
Following the investigations in AMG, now made it faster for analysis code to repeatedly check for missing objects.
The trigger for these updates was that a job created by @tdado using top-xaod would produce a profile like the following in VTune:
(This is from processing 20k ttbar events with one particular job setup.)
As it turned out, when analysis code uses xAOD::TEvent::contains<...>(...)
to check if it should do something, the old code ended up calling TTree::GetBranch(...) for missing containers/branches every time that xAOD::TEvent::contains<...>(...)
was called.
- First off I replaced the
TTree::GetBranch(...)
call by a faster search among the top-level branches of the tree. - But even more importantly,
xAOD::TEvent
was taught to remember what branches/objects it already looked for, but didn't find. So that on subsequent calls it would be able to determine more quickly that the object/branch is (still) missing.
With those two updates the xAOD::TEvent::contains<...>(...)
and xAOD::TEvent::connectBranch(...)
calls practically disappeared from the profile.
As expected xAODRootAccess is not missing from the profiles, since I/O is still a significant part of this job.
But to understand those, we'll have to have a look at the MET code, which seems to use most of the xAODRootAccess code after these updates...