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

promoting as a member of DQMStore and remove static #4756

Merged
merged 4 commits into from Jul 29, 2014

Conversation

deguio
Copy link
Contributor

@deguio deguio commented Jul 23, 2014

No description provided.

@cmsbuild
Copy link
Contributor

A new Pull Request was created by @deguio for CMSSW_7_2_X.

promoting as a member of DQMStore and remove static

It involves the following packages:

DQMServices/Core

@ojeda, @danduggan, @rovere, @cmsbuild, @nclopezo, @deguio, @Degano can you please review it and eventually sign? Thanks.
@barvic 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.

@cmsbuild
Copy link
Contributor

Pull request #4756 was updated. @ojeda, @danduggan, @rovere, @cmsbuild, @nclopezo, @deguio, @Degano can you please check and sign again.

@Dr15Jones
Copy link
Contributor

-1 I'm afraid this isn't thread safe and functions in Services do need to be thread safe.
The problem is two threads could be trying to set the pointer at the same time. I'll put the needed changes as comments to the appropriate lines of code.

@@ -19,6 +19,7 @@
# include <stdio.h>
# include <stdlib.h>
# include <cxxabi.h>
# include <iosfwd>
Copy link
Contributor

Choose a reason for hiding this comment

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

#include <atomic>

@rovere
Copy link
Contributor

rovere commented Jul 23, 2014

Ciao Chris,
of course I agree w/ your changes, yet my understanding is that:

  1. there will be 1 and only 1 instance of services (hence also of DQMStore), even if we run with several streams on several threads ==> no multiple constructors could ever be called at the same time: is this assumption correct?
  2. access to the print_trace function that uses the stream_ is protected by the lock in the iBooker interface.

Yet, as I said, it's better to be explicitly thread safe, rather than implicitely

thanks,
M.

@Dr15Jones
Copy link
Contributor

  1. We only create one instance of a Service and therefore you only have one constructor. When dealing with SubProcesses, however, it is possible to get multiple instances of a Service on different Processes, however I think the Service must at compile time explicitly tell the Service system it wants to be duplicated.
  2. If it is protected by iBooker then there is no need for the std::atomic. However, not all modules are using iBooker yet, isn't that correct? The reason is although setting stream_ is safe with the changes I made, calling methods of stream_ are not safe since I don't think std::ofstream itself is thread safe and therefore it requires a serialization mechanism to protect it.

@rovere
Copy link
Contributor

rovere commented Jul 23, 2014

Ciao Chris,
regarding point 2, the lock in iBooker will be hold until after the booking is finished and all calls to print_trace have returned, so I do not see concurrency problems here, right?

@Dr15Jones
Copy link
Contributor

Ciao Marco,
The problem is with legacy DQM modules which book during the Event processing. Searching for 'print_trace' in today's static analyzer output:
https://cmssdt.cern.ch/SDT/jenkins-artifacts/ib-static-analysis/CMSSW_7_2_X_2014-07-23-0200/slc6_amd64_gcc481/reports/modules2statics.txt

I found
In call stack ' BeamMonitor::analyze() calls function DQMStore::book1D() calls function DQMStore::book1D() calls function DQMStore::book() calls function DQMStore::print_trace() static variable DQMStore::print_trace()::stream' is accessed , 'BeamMonitor::analyze()' overrides 'edm::EDAnalyzer::analyze() virtual'

In call stack ' CastorMonitorModule::analyze() calls function CastorLEDMonitor::processEvent() calls function CastorLEDMonitor::perChanHists() calls function DQMStore::book1D() calls function DQMStore::book1D() calls function DQMStore::book() calls function DQMStore::print_trace() static variable DQMStore::print_trace()::stream' is accessed , 'CastorMonitorModule::analyze()' overrides 'edm::EDAnalyzer::analyze() virtual'

In call stack ' DTDigiForNoiseTask::analyze() calls function DTDigiForNoiseTask::bookHistos() calls function DQMStore::book2D() calls function DQMStore::book2D() calls function DQMStore::book() calls function DQMStore::print_trace() static variable DQMStore::print_trace()::stream' is accessed , 'DTDigiForNoiseTask::analyze()' overrides 'edm::EDAnalyzer::analyze() virtual'

In call stack ' DTDigiTask::analyze() calls function DTDigiTask::bookHistos() calls function DQMStore::book2D() calls function DQMStore::book2D() calls function DQMStore::book() calls function DQMStore::print_trace() static variable DQMStore::print_trace()::stream' is accessed , 'DTDigiTask::analyze()' overrides 'edm::EDAnalyzer::analyze() virtual'

In call stack ' DTEfficiencyTask::analyze() calls function DTEfficiencyTask::fillHistos() calls function DTEfficiencyTask::bookHistos() calls function DQMStore::book1D() calls function DQMStore::book1D() calls function DQMStore::book() calls function DQMStore::print_trace() static variable DQMStore::print_trace()::stream' is accessed , 'DTEfficiencyTask::analyze()' overrides 'edm::EDAnalyzer::analyze() virtual'

In call stack ' DTLocalTriggerTask::analyze() calls function DTLocalTriggerTask::runDCCAnalysis() calls function DTLocalTriggerTask::bookHistos() calls function DQMStore::book2D() calls function DQMStore::book2D() calls function DQMStore::book() calls function DQMStore::print_trace() static variable DQMStore::print_trace()::stream' is accessed , 'DTLocalTriggerTask::analyze()' overrides 'edm::EDAnalyzer::analyze() virtual'

In call stack ' DTTestPulsesTask::analyze() calls function DTTestPulsesTask::bookHistos() calls function DQMStore::bookProfile() calls function DQMStore::bookProfile() calls function DQMStore::book() calls function DQMStore::print_trace() static variable DQMStore::print_trace()::stream' is accessed , 'DTTestPulsesTask::analyze()' overrides 'edm::EDAnalyzer::analyze() virtual'

There are more but I stopped after the 'D's. Now because these are legacy modules, the framework will only execute one at a time so there is no danger of simulateous calls to DQMStore::print_trace from them. However, in the highly unlikely event that someone books DQMStore histograms using the old interface and changed their modules to be a stream module then we'd have a threading problem.

@rovere
Copy link
Contributor

rovere commented Jul 23, 2014

Ciao Chris,
indeed you are right and the situation is fishy at the moment. Yet our final goal is to shutdown completely the old interface of DQMStore/booking once all modules will be converted. So in this intermediate situation we could have problems, I agree, yet maybe we should code for the future and not too much for the present? I'd avoid complexity if in the end it will not be needed. Or we can add complexity now and remove it after the transition is over.

Especially in this case, since this piece of code is used for "private" debugging from the DQM Team, never in production.

I'll leave the choice to Fede (and you, of course, since you already gave -1 ;( )

Ciao e grazie,
M.

@Dr15Jones
Copy link
Contributor

My -1 doesn't mean anything to our integration system.
Given the discussion, I don't think it is worth changing the code to use std::atomic<>. However, it would be good to comment the code where stream_ is set to say why it is thread safe (i.e. iBooker protects it).

@deguio
Copy link
Contributor Author

deguio commented Jul 23, 2014

+1
thanks Marco and Chris. I have added a comment to the code.

@cmsbuild
Copy link
Contributor

This pull request is fully signed and it will be integrated in one of the next CMSSW_7_2_X IBs unless changes or unless it breaks tests.

@cmsbuild
Copy link
Contributor

-1

Tested at: a1ba043
I ran the usual tests and I found errors in the following unit tests:

---> test DQMQualityTestsExample had ERRORS
---> test TestDQMServicesFwkIOScripts had ERRORS

you can see the results of the tests here:
https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-4756/440/summary.html

@cmsbuild
Copy link
Contributor

This pull request is fully signed and it will be integrated in one of the next CMSSW_7_2_X IBs unless changes (but tests are reportedly failing).

@cmsbuild
Copy link
Contributor

-1

Tested at: a1ba043
I ran the usual tests and I found errors in the following unit tests:

---> test DQMQualityTestsExample had ERRORS
---> test TestDQMServicesFwkIOScripts had ERRORS

you can see the results of the tests here:
https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-4756/454/summary.html

@cmsbuild
Copy link
Contributor

Pull request #4756 was updated. @ojeda, @danduggan, @rovere, @cmsbuild, @nclopezo, @deguio, @Degano can you please check and sign again.

@cmsbuild
Copy link
Contributor

@cmsbuild
Copy link
Contributor

@cmsbuild
Copy link
Contributor

@cmsbuild
Copy link
Contributor

@deguio
Copy link
Contributor Author

deguio commented Jul 29, 2014

+1

@cmsbuild
Copy link
Contributor

This pull request is fully signed and it will be integrated in one of the next CMSSW_7_2_X IBs unless changes (tests are also fine).

nclopezo added a commit that referenced this pull request Jul 29, 2014
DQMServices -- promoting as a member of DQMStore and remove static
@nclopezo nclopezo merged commit a7c6ae4 into cms-sw:CMSSW_7_2_X Jul 29, 2014
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