New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cache the mapping from type_info to TypeWithDict for use in ObjectWithDict::dynamicType() #23059
Cache the mapping from type_info to TypeWithDict for use in ObjectWithDict::dynamicType() #23059
Conversation
…ynamicType() to use it
The code-checks are being triggered in jenkins. |
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-23059/4464 |
A new Pull Request was created by @dan131riley (Dan Riley) for master. It involves the following packages: FWCore/Utilities @cmsbuild, @smuzaffar, @Dr15Jones can you please review it and eventually sign? Thanks. cms-bot commands are listed here |
@dan131riley Just checking, this pull request alone will not see a speedup since the speedup also requires a change to the parser to call the new function? Answered myself: the parser calls |
FWCore/Utilities/src/TypeWithDict.cc
Outdated
} | ||
}; | ||
|
||
typedef tbb::concurrent_unordered_map<std::type_index, TypeWithDict, Hasher> TypeIndexMap; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about switching to the more modern, using
construct?
using TypeIndexMap = tbb::concurrent_unordered_map<std::type_index, TypeWithDict, Hasher>;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While there, please go ahead and change the other typedefs
as well. :).
@Dr15Jones the LazyInvoker calls |
The code-checks are being triggered in jenkins. |
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-23059/4465 |
Pull request #23059 was updated. @cmsbuild, @smuzaffar, @Dr15Jones can you please check and sign again. |
please test |
The tests are being triggered in jenkins. |
Comparison job queued. |
Comparison is ready Comparison Summary:
|
+1 |
This pull request is fully signed and it will be integrated in one of the next master IBs (tests are also fine). This pull request will now be reviewed by the release team before it's merged. @davidlange6, @slava77, @smuzaffar, @fabiocos (and backports should be raised in the release meeting by the corresponding L2) |
+1 |
In "lazy" evaluation mode (which @Dr15Jones wishes people wouldn't use), the expression evaluator calls
ObjectWithDict::dynamicType()
on every evaluation to check for virtual function overrides. That call creates a newTypeWithDict
for the real type of the variable using itsstd::type_info
andTClass::GetClass()
.GetClass()
traverses the ROOT global class list, taking at least a read lock on the list, leading to stack traces like this:In random stack samples and in the profiling tool "vtune", these calls are one of the leading causes of ROOT lock contention in a standard RAW2DIGI,L1Reco,RECO,EI,PAT job. This PR adds a map from
std::type_index
toTypeWithDict
, which is used to cache the results of these lookups. A new functionTypeWithDict::byTypeInfo()
populates and interrogates the map.Currently only
ObjectWithDict::dynamicType()
has been modified to use this cache. While other uses of theTypeWithDict
constructors could be modified to use this, in practice this PR plus #23058 are, in my test workflow, sufficient to eliminate all per-event calls toGetClass
due toTypeWithDict
construction.By removing potential lock contention for "lazy" uses of the cut parser, this PR improves the throughput and efficiency of my 24-core RECO test job by a modest but consistent 3%.