Skip to content
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

Make ElectronTagger thread safe #8284

Merged
merged 2 commits into from Mar 16, 2015

Conversation

Dr15Jones
Copy link
Contributor

Since the ElectronTagger can be obtained via the EventSetup, the
const methods of the class must be thread safe. This required replacing
TRandom3 with C++11 random facility (since TRandom3 uses a global seed)
and using an std::mutex to protect MvaSoftEleEstimator since the
way it interacts with TMVA::Reader is thread-unsafe.

Since the ElectronTagger can be obtained via the EventSetup, the
const methods of the class must be thread safe. This required replacing
TRandom3 with C++11 random facility (since TRandom3 uses a global seed)
and using an std::mutex to protect MvaSoftEleEstimator since the
way it interacts with TMVA::Reader is thread-unsafe.
@Dr15Jones
Copy link
Contributor Author

This problem was found by helgrind.

@cmsbuild
Copy link
Contributor

A new Pull Request was created by @Dr15Jones (Chris Jones) for CMSSW_7_4_X.

Make ElectronTagger thread safe

It involves the following packages:

RecoBTag/SoftLepton

@cmsbuild, @cvuosalo, @nclopezo, @slava77 can you please review it and eventually sign? Thanks.
@ferencek, @acaudron, @pvmulder, @imarches this is something you requested to watch as well.
You can sign-off by replying to this message having '+1' in the first line of your reply.
You can reject by replying to this message having '-1' in the first line of your reply.
If you are a L2 or a release manager you can ask for tests by saying 'please test' in the first line of a comment.
@Degano you are the release manager for this.
You can merge this pull request by typing 'merge' in the first line of your comment.

@ferencek
Copy link
Contributor

I guess the muon tagger should be fixed in a similar way since parts of the electron tagger code fixed by this PR are pretty much the same in the muon tagger.

@@ -11,13 +11,19 @@ float ElectronTagger::discriminator(const TagInfoHelper & tagInfo) const {
// default value, used if there are no leptons associated to this jet
float bestTag = - std::numeric_limits<float>::infinity();
const reco::CandSoftLeptonTagInfo & info = tagInfo.get<reco::CandSoftLeptonTagInfo>();

std::default_random_engine random;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the meaning of default_random_engine?
Is it reproducible across platforms?
Looking at www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3551.pdf (just google search)

default_random_engine, an alias for an engine type selected by the
library vendor
... distinct vendors are free to select differently
... code that uses this alias need not
generate identical sequences across implementations

TRandom3 is Mersenne twister engine; I'm not sure this randomness quality is really required here, but at least the specifications for it are defined.

@Dr15Jones
Copy link
Contributor Author

Please test

@Dr15Jones
Copy link
Contributor Author

I can switch to a set engine.

@cmsbuild
Copy link
Contributor

The tests are being triggered in jenkins.

Switch from the default random engine to the mersenne twister
in order to have reproducibility across platforms.
@Dr15Jones
Copy link
Contributor Author

Ping

@Dr15Jones
Copy link
Contributor Author

See #8304 for the Muon version

@Dr15Jones
Copy link
Contributor Author

Is there an ETA on approval? These fixes are needed to avoid problems in the threaded release.

@slava77
Copy link
Contributor

slava77 commented Mar 16, 2015

+1

for #8284 e5c6b6d
in addition to jenkins, tested locally with higher stats in CMSSW_7_4_X_2015-03-14-1400 /test area sign529/

there are no changes in monitored quantities, which suggests that the code affected by the random number selection/generation is actually not triggered (requires multiple candidates).

I ran igprof on ttbar with pu35@25ns and observed some minor increase in CPU in the two affected modules (by this and #8304 PR)

        softPFMuonBJetTags       0.65958 ms/ev -> 0.853296 ms/ev
        softPFElectronBJetTags   2.2377 ms/ev -> 2.42587 ms/ev

the increase is, unconvincingly, matching the igprof cost in MvaSoftEleEstimator::mvaValue, but maybe a jitter. The random engine-related elements are not showing up in igprof.

@cmsbuild
Copy link
Contributor

This pull request is fully signed and it will be integrated in one of the next CMSSW_7_4_X IBs unless changes (tests are also fine). This pull request requires discussion in the ORP meeting before it's merged. @davidlange6, @Degano, @ktf, @smuzaffar

@davidlange6
Copy link
Contributor

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants