Skip to content

Commit

Permalink
Merge pull request #1034 from wmtan/NoGlobalUpdatesInSecondarySource
Browse files Browse the repository at this point in the history
Multithreaded framework -- Don't update global registries in secondary source
  • Loading branch information
ktf committed Oct 9, 2013
2 parents 987f4b2 + 0630558 commit ecc0b4a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
29 changes: 19 additions & 10 deletions IOPool/Input/src/RootFile.cc
Expand Up @@ -339,7 +339,10 @@ namespace edm {
for(auto const& psetEntry : psetMap) {
ParameterSet pset(psetEntry.second.pset());
pset.setID(psetEntry.first);
psetRegistry.insertMapped(pset);
// For thread safety, don't update global registries when a secondary source opens a file.
if(inputType != InputType::SecondarySource) {
psetRegistry.insertMapped(pset);
}
}
}
if(!fileFormatVersion().splitProductIDs()) {
Expand Down Expand Up @@ -412,7 +415,7 @@ namespace edm {

// Here, we make the class that will make the ProvenanceReader
// It reads whatever trees it needs.
provenanceReaderMaker_.reset(makeProvenanceReaderMaker().release());
provenanceReaderMaker_.reset(makeProvenanceReaderMaker(inputType).release());

// Merge into the hashed registries.
if(eventSkipperByID_ && eventSkipperByID_->somethingToSkip()) {
Expand Down Expand Up @@ -489,7 +492,7 @@ namespace edm {
}

void
RootFile::readEntryDescriptionTree(EntryDescriptionMap& entryDescriptionMap) {
RootFile::readEntryDescriptionTree(EntryDescriptionMap& entryDescriptionMap, InputType inputType) {
// Called only for old format files.
// We use a smart pointer so the tree will be deleted after use, and not kept for the life of the file.
std::unique_ptr<TTree> entryDescriptionTree(dynamic_cast<TTree*>(filePtr_->Get(poolNames::entryDescriptionTreeName().c_str())));
Expand Down Expand Up @@ -525,14 +528,17 @@ namespace edm {
daqProvenanceHelper_->parentageIDMap_.insert(std::make_pair(oldID, newID));
}
}
registry.insertMapped(parents);
// For thread safety, don't update global registries when a secondary source opens a file.
if(inputType != InputType::SecondarySource) {
registry.insertMapped(parents);
}
}
entryDescriptionTree->SetBranchAddress(poolNames::entryDescriptionIDBranchName().c_str(), nullptr);
entryDescriptionTree->SetBranchAddress(poolNames::entryDescriptionBranchName().c_str(), nullptr);
}

void
RootFile::readParentageTree() {
RootFile::readParentageTree(InputType inputType) {
// New format file
// We use a smart pointer so the tree will be deleted after use, and not kept for the life of the file.
std::unique_ptr<TTree> parentageTree(dynamic_cast<TTree*>(filePtr_->Get(poolNames::parentageTreeName().c_str())));
Expand All @@ -558,7 +564,10 @@ namespace edm {
daqProvenanceHelper_->parentageIDMap_.insert(std::make_pair(oldID, newID));
}
}
registry.insertMapped(parents);
// For thread safety, don't update global registries when a secondary source opens a file.
if(inputType != InputType::SecondarySource) {
registry.insertMapped(parents);
}
parentageIDLookup_.push_back(parents.id());
}
parentageTree->SetBranchAddress(poolNames::parentageBranchName().c_str(), nullptr);
Expand Down Expand Up @@ -1715,16 +1724,16 @@ namespace edm {
}

std::unique_ptr<MakeProvenanceReader>
RootFile::makeProvenanceReaderMaker() {
RootFile::makeProvenanceReaderMaker(InputType inputType) {
if(fileFormatVersion_.storedProductProvenanceUsed()) {
readParentageTree();
readParentageTree(inputType);
return std::unique_ptr<MakeProvenanceReader>(new MakeReducedProvenanceReader(parentageIDLookup_));
} else if(fileFormatVersion_.splitProductIDs()) {
readParentageTree();
readParentageTree(inputType);
return std::unique_ptr<MakeProvenanceReader>(new MakeFullProvenanceReader);
} else if(fileFormatVersion_.perEventProductIDs()) {
std::unique_ptr<EntryDescriptionMap> entryDescriptionMap(new EntryDescriptionMap);
readEntryDescriptionTree(*entryDescriptionMap);
readEntryDescriptionTree(*entryDescriptionMap, inputType);
return std::unique_ptr<MakeProvenanceReader>(new MakeOldProvenanceReader(std::move(entryDescriptionMap)));
} else {
return std::unique_ptr<MakeProvenanceReader>(new MakeDummyProvenanceReader);
Expand Down
6 changes: 3 additions & 3 deletions IOPool/Input/src/RootFile.h
Expand Up @@ -161,15 +161,15 @@ namespace edm {
void overrideRunNumber(EventID& id, bool isRealData);
std::string const& newBranchToOldBranch(std::string const& newBranch) const;
void dropOnInput(ProductRegistry& reg, ProductSelectorRules const& rules, bool dropDescendants, InputType inputType);
void readParentageTree();
void readEntryDescriptionTree(EntryDescriptionMap&); // backward compatibility
void readParentageTree(InputType inputType);
void readEntryDescriptionTree(EntryDescriptionMap& entryDescriptionMap, InputType inputType); // backward compatibility
void readEventHistoryTree();
bool isDuplicateEvent();

void initializeDuplicateChecker(std::vector<boost::shared_ptr<IndexIntoFile> > const& indexesIntoFiles,
std::vector<boost::shared_ptr<IndexIntoFile> >::size_type currentIndexIntoFile);

std::unique_ptr<MakeProvenanceReader> makeProvenanceReaderMaker();
std::unique_ptr<MakeProvenanceReader> makeProvenanceReaderMaker(InputType inputType);
boost::shared_ptr<ProductProvenanceRetriever> makeProductProvenanceRetriever();

std::string const file_;
Expand Down

0 comments on commit ecc0b4a

Please sign in to comment.