Skip to content

Commit

Permalink
Merge pull request #28505 from Dr15Jones/fasterEventPrincipal
Browse files Browse the repository at this point in the history
Faster setup of EventPrincipal
  • Loading branch information
cmsbuild authored Dec 5, 2019
2 parents 86d9bad + cb2084e commit d4151f4
Show file tree
Hide file tree
Showing 71 changed files with 248 additions and 294 deletions.
2 changes: 1 addition & 1 deletion DQMServices/FwkIO/plugins/DQMRootSource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ void DQMRootSource::readLuminosityBlock_(edm::LuminosityBlockPrincipal& lbCache)
edm::Service<edm::JobReport> jr;
jr->reportInputLumiSection(lbCache.id().run(), lbCache.id().luminosityBlock());

lbCache.fillLuminosityBlockPrincipal(processHistoryRegistryForUpdate());
lbCache.fillLuminosityBlockPrincipal(processHistoryRegistry().getMapped(lbCache.aux().processHistoryID()));
}

std::unique_ptr<edm::FileBlock> DQMRootSource::readFile_() {
Expand Down
2 changes: 1 addition & 1 deletion DQMServices/StreamerIO/plugins/DQMProtobufReader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void DQMProtobufReader::readLuminosityBlock_(edm::LuminosityBlockPrincipal& lbCa

edm::Service<edm::JobReport> jr;
jr->reportInputLumiSection(lbCache.id().run(), lbCache.id().luminosityBlock());
lbCache.fillLuminosityBlockPrincipal(processHistoryRegistryForUpdate());
lbCache.fillLuminosityBlockPrincipal(processHistoryRegistry().getMapped(lbCache.aux().processHistoryID()));
}

void DQMProtobufReader::beginLuminosityBlock(edm::LuminosityBlock& lb) {
Expand Down
12 changes: 3 additions & 9 deletions DataFormats/Common/interface/ProductData.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,9 @@ namespace edm {

void unsafe_resetProductData() const { wrapper_.reset(); }

void setProcessHistory(ProcessHistory const& ph) { prov_.setProcessHistory(ph); }

void setProvenance(ProductProvenanceRetriever const* provRetriever,
ProcessHistory const& ph,
ProductID const& pid) {
prov_.setProductID(pid);
prov_.setStore(provRetriever);
prov_.setProcessHistory(ph);
}
void setProvenance(ProductProvenanceRetriever const* provRetriever) { prov_.setStore(provRetriever); }

void setProductID(ProductID const& pid) { prov_.setProductID(pid); }

void setMergeableRunProductMetadata(MergeableRunProductMetadataBase const* mrpm) {
prov_.setMergeableRunProductMetadata(mrpm);
Expand Down
2 changes: 1 addition & 1 deletion DataFormats/FWLite/interface/HistoryGetterBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// Created: Wed Feb 10 11:15:16 CST 2010
//

#include "DataFormats/Provenance/interface/ProcessHistoryRegistry.h"
#include "DataFormats/Provenance/interface/ProcessHistory.h"

namespace fwlite {
class HistoryGetterBase {
Expand Down
6 changes: 0 additions & 6 deletions DataFormats/Provenance/interface/Provenance.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ namespace edm {
std::string const& productInstanceName() const { return stable().productInstanceName(); }
std::string const& friendlyClassName() const { return stable().friendlyClassName(); }
ProductProvenanceRetriever const* store() const { return store_; }
ProcessHistory const& processHistory() const { return stable().processHistory(); }
ProcessHistory const* processHistoryPtr() const { return stable().processHistoryPtr(); }
bool getProcessConfiguration(ProcessConfiguration& pc) const { return stable().getProcessConfiguration(pc); }
ReleaseVersion releaseVersion() const { return stable().releaseVersion(); }
std::set<std::string> const& branchAliases() const { return stable().branchAliases(); }

// Usually branchID() and originalBranchID() return exactly the same result.
Expand All @@ -80,8 +76,6 @@ namespace edm {

void setStore(ProductProvenanceRetriever const* store) { store_ = store; }

void setProcessHistory(ProcessHistory const& ph) { stable().setProcessHistory(ph); }

ProductID const& productID() const { return stable().productID(); }

void setProductID(ProductID const& pid) { stable().setProductID(pid); }
Expand Down
7 changes: 0 additions & 7 deletions DataFormats/Provenance/interface/StableProvenance.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,10 @@ namespace edm {
std::string const& processName() const { return branchDescription().processName(); }
std::string const& productInstanceName() const { return branchDescription().productInstanceName(); }
std::string const& friendlyClassName() const { return branchDescription().friendlyClassName(); }
ProcessHistory const& processHistory() const { return *processHistory_; }
ProcessHistory const* processHistoryPtr() const { return processHistory_; }
bool getProcessConfiguration(ProcessConfiguration& pc) const;
ReleaseVersion releaseVersion() const;
std::set<std::string> const& branchAliases() const { return branchDescription().branchAliases(); }

void write(std::ostream& os) const;

void setProcessHistory(ProcessHistory const& ph) { processHistory_ = &ph; }

ProductID const& productID() const { return productID_; }

void setProductID(ProductID const& pid) { productID_ = pid; }
Expand All @@ -66,7 +60,6 @@ namespace edm {
private:
std::shared_ptr<BranchDescription const> branchDescription_;
ProductID productID_;
ProcessHistory const* processHistory_; // We don't own this
};

inline std::ostream& operator<<(std::ostream& os, StableProvenance const& p) {
Expand Down
1 change: 0 additions & 1 deletion DataFormats/Provenance/src/Provenance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "DataFormats/Provenance/interface/MergeableRunProductMetadataBase.h"
#include "DataFormats/Provenance/interface/ProductProvenanceRetriever.h"
#include "DataFormats/Provenance/interface/ProcessConfiguration.h"
#include "DataFormats/Provenance/interface/ProcessHistoryRegistry.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/Registry.h"

Expand Down
13 changes: 1 addition & 12 deletions DataFormats/Provenance/src/StableProvenance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,7 @@ namespace edm {
StableProvenance::StableProvenance() : StableProvenance{std::shared_ptr<BranchDescription const>(), ProductID()} {}

StableProvenance::StableProvenance(std::shared_ptr<BranchDescription const> const& p, ProductID const& pid)
: branchDescription_(p), productID_(pid), processHistory_() {}

bool StableProvenance::getProcessConfiguration(ProcessConfiguration& pc) const {
return processHistory_->getConfigurationForProcess(processName(), pc);
}

ReleaseVersion StableProvenance::releaseVersion() const {
ProcessConfiguration pc;
assert(getProcessConfiguration(pc));
return pc.releaseVersion();
}
: branchDescription_(p), productID_(pid) {}

void StableProvenance::write(std::ostream& os) const {
// This is grossly inadequate, but it is not critical for the first pass.
Expand All @@ -38,6 +28,5 @@ namespace edm {
void StableProvenance::swap(StableProvenance& iOther) {
branchDescription_.swap(iOther.branchDescription_);
productID_.swap(iOther.productID_);
std::swap(processHistory_, iOther.processHistory_);
}
} // namespace edm
1 change: 0 additions & 1 deletion DataFormats/Provenance/test/indexIntoFile1_t.cppunit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "DataFormats/Provenance/interface/ProcessHistoryID.h"
#include "DataFormats/Provenance/interface/ProcessConfiguration.h"
#include "DataFormats/Provenance/interface/ProcessHistory.h"
#include "DataFormats/Provenance/interface/ProcessHistoryRegistry.h"

#include "DataFormats/Provenance/interface/IndexIntoFile.h"

Expand Down
1 change: 0 additions & 1 deletion DataFormats/Provenance/test/indexIntoFile2_t.cppunit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "DataFormats/Provenance/interface/ProcessHistoryID.h"
#include "DataFormats/Provenance/interface/ProcessConfiguration.h"
#include "DataFormats/Provenance/interface/ProcessHistory.h"
#include "DataFormats/Provenance/interface/ProcessHistoryRegistry.h"

#include "DataFormats/Provenance/interface/IndexIntoFile.h"

Expand Down
1 change: 0 additions & 1 deletion DataFormats/Provenance/test/indexIntoFile3_t.cppunit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "DataFormats/Provenance/interface/ProcessHistoryID.h"
#include "DataFormats/Provenance/interface/ProcessConfiguration.h"
#include "DataFormats/Provenance/interface/ProcessHistory.h"
#include "DataFormats/Provenance/interface/ProcessHistoryRegistry.h"

#include "DataFormats/Provenance/interface/IndexIntoFile.h"

Expand Down
1 change: 0 additions & 1 deletion DataFormats/Provenance/test/indexIntoFile4_t.cppunit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "DataFormats/Provenance/interface/ProcessHistoryID.h"
#include "DataFormats/Provenance/interface/ProcessConfiguration.h"
#include "DataFormats/Provenance/interface/ProcessHistory.h"
#include "DataFormats/Provenance/interface/ProcessHistoryRegistry.h"

#include "DataFormats/Provenance/interface/IndexIntoFile.h"

Expand Down
1 change: 0 additions & 1 deletion DataFormats/Provenance/test/indexIntoFile5_t.cppunit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "DataFormats/Provenance/interface/ProcessHistoryID.h"
#include "DataFormats/Provenance/interface/ProcessConfiguration.h"
#include "DataFormats/Provenance/interface/ProcessHistory.h"
#include "DataFormats/Provenance/interface/ProcessHistoryRegistry.h"

#include "DataFormats/Provenance/interface/IndexIntoFile.h"

Expand Down
1 change: 0 additions & 1 deletion DataFormats/Provenance/test/indexIntoFile_t.cppunit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "DataFormats/Provenance/interface/ProcessHistoryID.h"
#include "DataFormats/Provenance/interface/ProcessConfiguration.h"
#include "DataFormats/Provenance/interface/ProcessHistory.h"
#include "DataFormats/Provenance/interface/ProcessHistoryRegistry.h"

#include "DataFormats/Provenance/interface/IndexIntoFile.h"

Expand Down
5 changes: 3 additions & 2 deletions FWCore/Common/interface/Provenance.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

namespace edm {
class ParameterSet;
std::string moduleName(Provenance const& provenance);
ParameterSet const& parameterSet(Provenance const& provenance);
class ProcessHistory;
std::string moduleName(Provenance const& provenance, ProcessHistory const& history);
ParameterSet const& parameterSet(Provenance const& provenance, ProcessHistory const& history);
} // namespace edm
#endif
8 changes: 4 additions & 4 deletions FWCore/Common/src/Provenance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ namespace edm {
static std::string const source("source");
static std::string const triggerResultsInserter("TriggerResultsInserter");

ParameterSet const& parameterSet(Provenance const& provenance) {
ParameterSet const& parameterSet(Provenance const& provenance, ProcessHistory const& history) {
ProcessConfiguration pc;
provenance.getProcessConfiguration(pc);
history.getConfigurationForProcess(provenance.processName(), pc);
ParameterSet const& processParameterSet = *pset::Registry::instance()->getMapped(pc.parameterSetID());
std::string const& label = provenance.moduleLabel();
if (!processParameterSet.existsAs<ParameterSet>(label)) {
Expand All @@ -24,11 +24,11 @@ namespace edm {
return processParameterSet.getParameterSet(label);
}

std::string moduleName(Provenance const& provenance) {
std::string moduleName(Provenance const& provenance, ProcessHistory const& history) {
// Trigger results ia a special case
if (provenance.moduleLabel() == triggerResults) {
return triggerResultsInserter;
}
return parameterSet(provenance).getParameter<std::string>("@module_type");
return parameterSet(provenance, history).getParameter<std::string>("@module_type");
}
} // namespace edm
23 changes: 14 additions & 9 deletions FWCore/Framework/interface/EventPrincipal.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ namespace edm {
class StreamContext;
class ThinnedAssociation;
class ThinnedAssociationsHelper;
class ProcessHistoryRegistry;
class RunPrincipal;

class EventPrincipal : public Principal {
Expand All @@ -61,17 +60,17 @@ namespace edm {
~EventPrincipal() override {}

void fillEventPrincipal(EventAuxiliary const& aux,
ProcessHistoryRegistry const& processHistoryRegistry,
ProcessHistory const* processHistory,
DelayedReader* reader = nullptr);
void fillEventPrincipal(EventAuxiliary const& aux,
ProcessHistoryRegistry const& processHistoryRegistry,
EventSelectionIDVector&& eventSelectionIDs,
BranchListIndexes&& branchListIndexes);
ProcessHistory const* processHistory,
EventSelectionIDVector eventSelectionIDs,
BranchListIndexes branchListIndexes);
//provRetriever is changed via a call to ProductProvenanceRetriever::deepSwap
void fillEventPrincipal(EventAuxiliary const& aux,
ProcessHistoryRegistry const& processHistoryRegistry,
EventSelectionIDVector&& eventSelectionIDs,
BranchListIndexes&& branchListIndexes,
ProcessHistory const* processHistory,
EventSelectionIDVector eventSelectionIDs,
BranchListIndexes branchListIndexes,
ProductProvenanceRetriever const& provRetriever,
DelayedReader* reader = nullptr,
bool deepCopyRetriever = true);
Expand Down Expand Up @@ -157,6 +156,12 @@ namespace edm {
}
std::shared_ptr<ProductProvenanceRetriever>& provRetrieverPtr() { return get_underlying_safe(provRetrieverPtr_); }

bool wasBranchListIndexesChangedFromInput(BranchListIndexes const&) const;
void updateBranchListIndexes(BranchListIndexes&&);
void commonFillEventPrincipal(EventAuxiliary const& aux,
ProcessHistory const* processHistory,
DelayedReader* reader);

private:
EventAuxiliary aux_;

Expand All @@ -172,7 +177,7 @@ namespace edm {

BranchListIndexes branchListIndexes_;

std::map<BranchListIndex, ProcessIndex> branchListIndexToProcessIndex_;
std::vector<ProcessIndex> branchListIndexToProcessIndex_;

StreamID streamID_;
};
Expand Down
1 change: 0 additions & 1 deletion FWCore/Framework/interface/HistoryAppender.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
namespace edm {

class ProcessConfiguration;
class ProcessHistoryRegistry;

class HistoryAppender {
public:
Expand Down
4 changes: 1 addition & 3 deletions FWCore/Framework/interface/LuminosityBlockPrincipal.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ namespace edm {

class HistoryAppender;
class ModuleCallingContext;
class ProcessHistoryRegistry;
class RunPrincipal;

class LuminosityBlockPrincipal : public Principal {
Expand All @@ -41,8 +40,7 @@ namespace edm {

~LuminosityBlockPrincipal() override {}

void fillLuminosityBlockPrincipal(ProcessHistoryRegistry const& processHistoryRegistry,
DelayedReader* reader = nullptr);
void fillLuminosityBlockPrincipal(ProcessHistory const* processHistory, DelayedReader* reader = nullptr);

RunPrincipal const& runPrincipal() const { return *runPrincipal_; }

Expand Down
3 changes: 1 addition & 2 deletions FWCore/Framework/interface/Principal.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ namespace edm {
class HistoryAppender;
class MergeableRunProductMetadata;
class ModuleCallingContext;
class ProcessHistoryRegistry;
class ProductResolverIndexHelper;
class EDConsumerBase;
class SharedResourcesAcquirer;
Expand Down Expand Up @@ -81,7 +80,7 @@ namespace edm {

void adjustIndexesAfterProductRegistryAddition();

void fillPrincipal(ProcessHistoryID const& hist, ProcessHistoryRegistry const& phr, DelayedReader* reader);
void fillPrincipal(ProcessHistoryID const& hist, ProcessHistory const* phr, DelayedReader* reader);

void clearPrincipal();

Expand Down
20 changes: 8 additions & 12 deletions FWCore/Framework/interface/ProductResolverBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,21 +135,19 @@ namespace edm {
// Retrieves pointer to a class containing the event independent provenance.
StableProvenance const* stableProvenance() const { return &provenance()->stable(); }

// Initializes the event independent portion of the provenance, plus the process history ID, the product ID, and the provRetriever.
void setProvenance(ProductProvenanceRetriever const* provRetriever,
ProcessHistory const& ph,
ProductID const& pid) {
setProvenance_(provRetriever, ph, pid);
// Initialize the mechanism to retrieve per event provenance
void setProductProvenanceRetriever(ProductProvenanceRetriever const* provRetriever) {
setProductProvenanceRetriever_(provRetriever);
}

// Initializes the ProductID
void setProductID(ProductID const& pid) { setProductID_(pid); }

// Initializes the portion of the provenance related to mergeable run products.
void setMergeableRunProductMetadata(MergeableRunProductMetadata const* mrpm) {
setMergeableRunProductMetadata_(mrpm);
}

// Initializes the process history.
void setProcessHistory(ProcessHistory const& ph) { setProcessHistory_(ph); }

// Write the product to the stream.
void write(std::ostream& os) const;

Expand Down Expand Up @@ -201,11 +199,9 @@ namespace edm {
virtual void resetBranchDescription_(std::shared_ptr<BranchDescription const> bd) = 0;
virtual Provenance const* provenance_() const = 0;
virtual std::string const& resolvedModuleLabel_() const = 0;
virtual void setProvenance_(ProductProvenanceRetriever const* provRetriever,
ProcessHistory const& ph,
ProductID const& pid) = 0;
virtual void setProductProvenanceRetriever_(ProductProvenanceRetriever const* provRetriever) = 0;
virtual void setProductID_(ProductID const& pid) = 0;
virtual void setMergeableRunProductMetadata_(MergeableRunProductMetadata const*);
virtual void setProcessHistory_(ProcessHistory const& ph) = 0;
virtual ProductProvenance const* productProvenancePtr_() const = 0;
virtual void resetProductData_(bool deleteEarly) = 0;
virtual bool singleProduct_() const = 0;
Expand Down
1 change: 1 addition & 0 deletions FWCore/Framework/interface/RunPrincipal.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ namespace edm {
class MergeableRunProductProcesses;
class MergeableRunProductMetadata;
class ModuleCallingContext;
class ProcessHistoryRegistry;

class RunPrincipal : public Principal {
public:
Expand Down
3 changes: 2 additions & 1 deletion FWCore/Framework/interface/getProducerParameterSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ namespace edm {

class ParameterSet;
class Provenance;
class ProcessHistory;

ParameterSet const* getProducerParameterSet(Provenance const& provenance);
ParameterSet const* getProducerParameterSet(Provenance const& provenance, ProcessHistory const&);
} // namespace edm
#endif
1 change: 0 additions & 1 deletion FWCore/Framework/src/Event.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "FWCore/Framework/interface/Event.h"

#include "DataFormats/Common/interface/TriggerResults.h"
#include "DataFormats/Provenance/interface/ProcessHistoryRegistry.h"
#include "DataFormats/Provenance/interface/Provenance.h"
#include "DataFormats/Provenance/interface/StableProvenance.h"
#include "DataFormats/Provenance/interface/ParentageRegistry.h"
Expand Down
1 change: 0 additions & 1 deletion FWCore/Framework/src/EventForOutput.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "FWCore/Framework/interface/EventForOutput.h"

#include "DataFormats/Common/interface/TriggerResults.h"
#include "DataFormats/Provenance/interface/ProcessHistoryRegistry.h"
#include "FWCore/Common/interface/TriggerResultsByName.h"
#include "FWCore/Framework/interface/EventPrincipal.h"
#include "FWCore/Framework/interface/LuminosityBlockForOutput.h"
Expand Down
Loading

0 comments on commit d4151f4

Please sign in to comment.