Skip to content

Commit

Permalink
Merge pull request #36400 from makortel/preOpenFileUsedFallback
Browse files Browse the repository at this point in the history
Remove usedFallback argument from (pre|post)(Open|Close)File
  • Loading branch information
cmsbuild authored Dec 9, 2021
2 parents 9d1098c + 67ebd70 commit 0197d42
Show file tree
Hide file tree
Showing 17 changed files with 66 additions and 77 deletions.
10 changes: 4 additions & 6 deletions FWCore/Framework/interface/InputSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,8 @@ namespace edm {

class FileOpenSentry {
public:
typedef signalslot::Signal<void(std::string const&, bool)> Sig;
explicit FileOpenSentry(InputSource const& source, std::string const& lfn, bool usedFallback);
typedef signalslot::Signal<void(std::string const&)> Sig;
explicit FileOpenSentry(InputSource const& source, std::string const& lfn);
~FileOpenSentry();

FileOpenSentry(FileOpenSentry const&) = delete; // Disallow copying and moving
Expand All @@ -300,13 +300,12 @@ namespace edm {
private:
Sig& post_;
std::string const& lfn_;
bool usedFallback_;
};

class FileCloseSentry {
public:
typedef signalslot::Signal<void(std::string const&, bool)> Sig;
explicit FileCloseSentry(InputSource const& source, std::string const& lfn, bool usedFallback);
typedef signalslot::Signal<void(std::string const&)> Sig;
explicit FileCloseSentry(InputSource const& source, std::string const& lfn);
~FileCloseSentry();

FileCloseSentry(FileCloseSentry const&) = delete; // Disallow copying and moving
Expand All @@ -315,7 +314,6 @@ namespace edm {
private:
Sig& post_;
std::string const& lfn_;
bool usedFallback_;
};

signalslot::Signal<void(StreamContext const&, ModuleCallingContext const&)> preEventReadFromSourceSignal_;
Expand Down
16 changes: 8 additions & 8 deletions FWCore/Framework/src/InputSource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -495,17 +495,17 @@ namespace edm {
source_.actReg()->postSourceProcessBlockSignal_(processName_);
}

InputSource::FileOpenSentry::FileOpenSentry(InputSource const& source, std::string const& lfn, bool usedFallback)
: post_(source.actReg()->postOpenFileSignal_), lfn_(lfn), usedFallback_(usedFallback) {
source.actReg()->preOpenFileSignal_(lfn, usedFallback);
InputSource::FileOpenSentry::FileOpenSentry(InputSource const& source, std::string const& lfn)
: post_(source.actReg()->postOpenFileSignal_), lfn_(lfn) {
source.actReg()->preOpenFileSignal_(lfn);
}

InputSource::FileOpenSentry::~FileOpenSentry() { post_(lfn_, usedFallback_); }
InputSource::FileOpenSentry::~FileOpenSentry() { post_(lfn_); }

InputSource::FileCloseSentry::FileCloseSentry(InputSource const& source, std::string const& lfn, bool usedFallback)
: post_(source.actReg()->postCloseFileSignal_), lfn_(lfn), usedFallback_(usedFallback) {
source.actReg()->preCloseFileSignal_(lfn, usedFallback);
InputSource::FileCloseSentry::FileCloseSentry(InputSource const& source, std::string const& lfn)
: post_(source.actReg()->postCloseFileSignal_), lfn_(lfn) {
source.actReg()->preCloseFileSignal_(lfn);
}

InputSource::FileCloseSentry::~FileCloseSentry() { post_(lfn_, usedFallback_); }
InputSource::FileCloseSentry::~FileCloseSentry() { post_(lfn_); }
} // namespace edm
8 changes: 4 additions & 4 deletions FWCore/Integration/test/unit_test_outputs/testGetBy2.log
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
++ starting: constructing source: PoolSource
Module type=PoolSource, Module label=source, Parameter Set ID=079a79e873959edf4ff4f335f14507fa
++++ starting: open input file: lfn = file:testGetBy1.root usedFallBack = 0
++++ finished: open input file: lfn = file:testGetBy1.root usedFallBack = 0
++++ starting: open input file: lfn = file:testGetBy1.root
++++ finished: open input file: lfn = file:testGetBy1.root
++ finished: constructing source: PoolSource
Module type=PoolSource, Module label=source, Parameter Set ID=079a79e873959edf4ff4f335f14507fa
++++ starting: constructing module with label 'TriggerResults' id = 1
Expand Down Expand Up @@ -791,8 +791,8 @@ GlobalContext: transition = WriteRun
runIndex = 0 luminosityBlockIndex = 4294967295 unixTime = 0 microsecondOffset = 15000001
ProcessContext: PROD2 7da3661f4f7dead5e42f07cf3ddf5a59

++++ starting: close input file: lfn = file:testGetBy1.root usedFallBack = 0
++++ finished: close input file: lfn = file:testGetBy1.root usedFallBack = 0
++++ starting: close input file: lfn = file:testGetBy1.root
++++ finished: close input file: lfn = file:testGetBy1.root
++++ starting: end process block
GlobalContext: transition = EndProcessBlock
run: 0 luminosityBlock: 0
Expand Down
6 changes: 3 additions & 3 deletions FWCore/MessageService/plugins/MessageLogger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -748,9 +748,9 @@ namespace edm {
void MessageLogger::preSourceRunLumi() { establish("source"); }
void MessageLogger::postSourceRunLumi() { unEstablish("AfterSource"); }

void MessageLogger::preFile(std::string const&, bool) { establish("file_open"); }
void MessageLogger::preFileClose(std::string const&, bool) { establish("file_close"); }
void MessageLogger::postFile(std::string const&, bool) { unEstablish("AfterFile"); }
void MessageLogger::preFile(std::string const&) { establish("file_open"); }
void MessageLogger::preFileClose(std::string const&) { establish("file_close"); }
void MessageLogger::postFile(std::string const&) { unEstablish("AfterFile"); }

void MessageLogger::preEvent(StreamContext const& iContext) {
assert(iContext.streamID().value() < transitionInfoCache_.size());
Expand Down
6 changes: 3 additions & 3 deletions FWCore/MessageService/plugins/MessageLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ namespace edm {
void preSourceRunLumi();
void postSourceRunLumi();

void preFile(std::string const&, bool);
void preFileClose(std::string const&, bool);
void postFile(std::string const&, bool);
void preFile(std::string const&);
void preFileClose(std::string const&);
void postFile(std::string const&);

void preModuleConstruction(ModuleDescription const&);
void postModuleConstruction(ModuleDescription const&);
Expand Down
21 changes: 10 additions & 11 deletions FWCore/ServiceRegistry/interface/ActivityRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,31 +231,30 @@ namespace edm {
AR_WATCH_USING_METHOD_1(watchPostSourceProcessBlock)

/// signal is emitted before the source opens a file
typedef signalslot::Signal<void(std::string const&, bool)> PreOpenFile;
typedef signalslot::Signal<void(std::string const&)> PreOpenFile;
PreOpenFile preOpenFileSignal_;
void watchPreOpenFile(PreOpenFile::slot_type const& iSlot) { preOpenFileSignal_.connect(iSlot); }
AR_WATCH_USING_METHOD_2(watchPreOpenFile)
AR_WATCH_USING_METHOD_1(watchPreOpenFile)

/// signal is emitted after the source opens a file
// Note this is only done for a primary file, not a secondary one.
typedef signalslot::Signal<void(std::string const&, bool)> PostOpenFile;
typedef signalslot::Signal<void(std::string const&)> PostOpenFile;
PostOpenFile postOpenFileSignal_;
void watchPostOpenFile(PostOpenFile::slot_type const& iSlot) { postOpenFileSignal_.connect_front(iSlot); }
AR_WATCH_USING_METHOD_2(watchPostOpenFile)
AR_WATCH_USING_METHOD_1(watchPostOpenFile)

/// signal is emitted before the Closesource closes a file
/// signal is emitted before the source closes a file
// First argument is the LFN of the file which is being closed.
// Second argument is false if fallback is used; true otherwise.
typedef signalslot::Signal<void(std::string const&, bool)> PreCloseFile;
typedef signalslot::Signal<void(std::string const&)> PreCloseFile;
PreCloseFile preCloseFileSignal_;
void watchPreCloseFile(PreCloseFile::slot_type const& iSlot) { preCloseFileSignal_.connect(iSlot); }
AR_WATCH_USING_METHOD_2(watchPreCloseFile)
AR_WATCH_USING_METHOD_1(watchPreCloseFile)

/// signal is emitted after the source opens a file
typedef signalslot::Signal<void(std::string const&, bool)> PostCloseFile;
/// signal is emitted after the source closes a file
typedef signalslot::Signal<void(std::string const&)> PostCloseFile;
PostCloseFile postCloseFileSignal_;
void watchPostCloseFile(PostCloseFile::slot_type const& iSlot) { postCloseFileSignal_.connect_front(iSlot); }
AR_WATCH_USING_METHOD_2(watchPostCloseFile)
AR_WATCH_USING_METHOD_1(watchPostCloseFile)

typedef signalslot::Signal<void(StreamContext const&, ModuleCallingContext const&)> PreModuleBeginStream;
PreModuleBeginStream preModuleBeginStreamSignal_;
Expand Down
8 changes: 4 additions & 4 deletions FWCore/Services/plugins/CheckTransitions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ namespace edm {
void preBeginJob(PathsAndConsumesOfModulesBase const&, ProcessContext const&);
void postEndJob();

void preOpenFile(std::string const&, bool);
void preOpenFile(std::string const&);

void preCloseFile(std::string const& lfn, bool primary);
void preCloseFile(std::string const& lfn);

void preGlobalBeginRun(GlobalContext const&);

Expand Down Expand Up @@ -283,9 +283,9 @@ void CheckTransitions::postEndJob() {
}
}

void CheckTransitions::preOpenFile(std::string const& lfn, bool b) {}
void CheckTransitions::preOpenFile(std::string const& lfn) {}

void CheckTransitions::preCloseFile(std::string const& lfn, bool b) {}
void CheckTransitions::preCloseFile(std::string const& lfn) {}

void CheckTransitions::preGlobalBeginRun(GlobalContext const& gc) {
auto id = gc.luminosityBlockID();
Expand Down
4 changes: 2 additions & 2 deletions FWCore/Services/plugins/CondorStatusUpdater.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace edm {
void beginPre(PathsAndConsumesOfModulesBase const &, ProcessContext const &processContext);
void beginPost();
void endPost();
void filePost(std::string const &, bool);
void filePost(std::string const &);

bool m_debug;
std::atomic_flag m_shouldUpdate;
Expand Down Expand Up @@ -136,7 +136,7 @@ void CondorStatusService::runPost(GlobalContext const &) {
update();
}

void CondorStatusService::filePost(std::string const & /*lfn*/, bool /*usedFallback*/) {
void CondorStatusService::filePost(std::string const & /*lfn*/) {
m_files++;
update();
}
Expand Down
8 changes: 4 additions & 4 deletions FWCore/Services/plugins/Timing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ namespace edm {
void preSourceRun(RunIndex);
void postSourceRun(RunIndex);

void preOpenFile(std::string const&, bool);
void postOpenFile(std::string const&, bool);
void preOpenFile(std::string const&);
void postOpenFile(std::string const&);

void preModule(ModuleDescription const& md);
void postModule(ModuleDescription const& md);
Expand Down Expand Up @@ -553,9 +553,9 @@ namespace edm {

void Timing::postSourceRun(RunIndex index) { postCommon(); }

void Timing::preOpenFile(std::string const& lfn, bool b) { pushStack(configuredInTopLevelProcess_); }
void Timing::preOpenFile(std::string const& lfn) { pushStack(configuredInTopLevelProcess_); }

void Timing::postOpenFile(std::string const& lfn, bool b) { postCommon(); }
void Timing::postOpenFile(std::string const& lfn) { postCommon(); }

void Timing::preModule(ModuleDescription const&) { pushStack(configuredInTopLevelProcess_); }

Expand Down
24 changes: 8 additions & 16 deletions FWCore/Services/plugins/Tracer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ namespace edm {
void preSourceProcessBlock();
void postSourceProcessBlock(std::string const&);

void preOpenFile(std::string const&, bool);
void postOpenFile(std::string const&, bool);
void preOpenFile(std::string const&);
void postOpenFile(std::string const&);

void preCloseFile(std::string const& lfn, bool primary);
void postCloseFile(std::string const&, bool);
void preCloseFile(std::string const& lfn);
void postCloseFile(std::string const&);

void preModuleBeginStream(StreamContext const&, ModuleCallingContext const&);
void postModuleBeginStream(StreamContext const&, ModuleCallingContext const&);
Expand Down Expand Up @@ -603,35 +603,27 @@ void Tracer::postSourceProcessBlock(std::string const& processName) {
<< " finished: source process block " << processName;
}

void Tracer::preOpenFile(std::string const& lfn, bool b) {
void Tracer::preOpenFile(std::string const& lfn) {
LogAbsolute out("Tracer");
out << TimeStamper(printTimestamps_);
out << indention_ << indention_ << " starting: open input file: lfn = " << lfn;
if (dumpNonModuleContext_)
out << " usedFallBack = " << b;
}

void Tracer::postOpenFile(std::string const& lfn, bool b) {
void Tracer::postOpenFile(std::string const& lfn) {
LogAbsolute out("Tracer");
out << TimeStamper(printTimestamps_);
out << indention_ << indention_ << " finished: open input file: lfn = " << lfn;
if (dumpNonModuleContext_)
out << " usedFallBack = " << b;
}

void Tracer::preCloseFile(std::string const& lfn, bool b) {
void Tracer::preCloseFile(std::string const& lfn) {
LogAbsolute out("Tracer");
out << TimeStamper(printTimestamps_);
out << indention_ << indention_ << " starting: close input file: lfn = " << lfn;
if (dumpNonModuleContext_)
out << " usedFallBack = " << b;
}
void Tracer::postCloseFile(std::string const& lfn, bool b) {
void Tracer::postCloseFile(std::string const& lfn) {
LogAbsolute out("Tracer");
out << TimeStamper(printTimestamps_);
out << indention_ << indention_ << " finished: close input file: lfn = " << lfn;
if (dumpNonModuleContext_)
out << " usedFallBack = " << b;
}

void Tracer::preModuleBeginStream(StreamContext const& sc, ModuleCallingContext const& mcc) {
Expand Down
16 changes: 8 additions & 8 deletions HeterogeneousCore/CUDAServices/plugins/NVProfilerService.cc
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,12 @@ class NVProfilerService {
void postModuleEventPrefetching(edm::StreamContext const&, edm::ModuleCallingContext const&);

// these signal pair are guaranteed to be called by the same thread
void preOpenFile(std::string const&, bool);
void postOpenFile(std::string const&, bool);
void preOpenFile(std::string const&);
void postOpenFile(std::string const&);

// these signal pair are guaranteed to be called by the same thread
void preCloseFile(std::string const&, bool);
void postCloseFile(std::string const&, bool);
void preCloseFile(std::string const&);
void postCloseFile(std::string const&);

// these signal pair are guaranteed to be called by the same thread
void preSourceConstruction(edm::ModuleDescription const&);
Expand Down Expand Up @@ -585,25 +585,25 @@ void NVProfilerService::postSourceRun(edm::RunIndex index) {
}
}

void NVProfilerService::preOpenFile(std::string const& lfn, bool) {
void NVProfilerService::preOpenFile(std::string const& lfn) {
if (not skipFirstEvent_ or globalFirstEventDone_) {
nvtxDomainRangePush(global_domain_, ("open file "s + lfn).c_str());
}
}

void NVProfilerService::postOpenFile(std::string const& lfn, bool) {
void NVProfilerService::postOpenFile(std::string const& lfn) {
if (not skipFirstEvent_ or globalFirstEventDone_) {
nvtxDomainRangePop(global_domain_);
}
}

void NVProfilerService::preCloseFile(std::string const& lfn, bool) {
void NVProfilerService::preCloseFile(std::string const& lfn) {
if (not skipFirstEvent_ or globalFirstEventDone_) {
nvtxDomainRangePush(global_domain_, ("close file "s + lfn).c_str());
}
}

void NVProfilerService::postCloseFile(std::string const& lfn, bool) {
void NVProfilerService::postCloseFile(std::string const& lfn) {
if (not skipFirstEvent_ or globalFirstEventDone_) {
nvtxDomainRangePop(global_domain_);
}
Expand Down
2 changes: 1 addition & 1 deletion IOPool/Input/src/RootInputFileSequence.cc
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ namespace edm {
std::list<std::string> exInfo;
{
std::unique_ptr<InputSource::FileOpenSentry> sentry(
input ? std::make_unique<InputSource::FileOpenSentry>(*input, lfn_, false) : nullptr);
input ? std::make_unique<InputSource::FileOpenSentry>(*input, lfn_) : nullptr);
edm::Service<edm::storage::StatisticsSenderService> service;
if (service.isAvailable()) {
service->openingFile(lfn(), inputType, -1);
Expand Down
2 changes: 1 addition & 1 deletion IOPool/Input/src/RootPrimaryFileSequence.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ namespace edm {
void RootPrimaryFileSequence::closeFile_() {
// close the currently open file, if any, and delete the RootFile object.
if (rootFile()) {
auto sentry = std::make_unique<InputSource::FileCloseSentry>(input_, lfn(), usedFallback());
auto sentry = std::make_unique<InputSource::FileCloseSentry>(input_, lfn());
rootFile()->close();
if (duplicateChecker_)
duplicateChecker_->inputFileClosed();
Expand Down
4 changes: 2 additions & 2 deletions IgTools/IgProf/plugins/IgProfService.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ void IgProfService::postEndRun(GlobalContext const &) { makeDump(atPostEndRun_);

void IgProfService::postEndJob() { makeDump(atPostEndJob_); }

void IgProfService::postOpenFile(std::string const &, bool) {
void IgProfService::postOpenFile(std::string const &) {
++nfileopened_;
makeDump(atPostOpenFile_);
}

void IgProfService::postCloseFile(std::string const &, bool) {
void IgProfService::postCloseFile(std::string const &) {
++nfileclosed_;
makeDump(atPostCloseFile_);
}
Expand Down
4 changes: 2 additions & 2 deletions IgTools/IgProf/plugins/IgProfService.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ namespace edm {

void postEndJob();

void postOpenFile(std::string const &, bool);
void postOpenFile(std::string const &);

void postCloseFile(std::string const &, bool);
void postCloseFile(std::string const &);

inline bool isProcessWideService(IgProfService const *) { return true; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace edm {
void closedFile(std::string const& lfn, bool usedFallback);

private:
void filePostCloseEvent(std::string const& lfn, bool usedFallback);
void filePostCloseEvent(std::string const& lfn);

std::string const* matchedLfn(std::string const& iURL); //updates its internal cache
class FileStatistics {
Expand Down
2 changes: 1 addition & 1 deletion Utilities/StorageFactory/src/StatisticsSenderService.cc
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ void StatisticsSenderService::setSize(const std::string &url, size_t size) {
}
}

void StatisticsSenderService::filePostCloseEvent(std::string const &lfn, bool usedFallback) {
void StatisticsSenderService::filePostCloseEvent(std::string const &lfn) {
//we are at a sync point in the framwework so no new files are being opened
cleanupOldFiles();
m_filestats.update();
Expand Down

0 comments on commit 0197d42

Please sign in to comment.