Skip to content

Commit

Permalink
Print ES module dependences from Tracer
Browse files Browse the repository at this point in the history
  • Loading branch information
wddgit committed Dec 12, 2024
1 parent 2883d1e commit 66bc924
Show file tree
Hide file tree
Showing 39 changed files with 1,880 additions and 341 deletions.
2 changes: 2 additions & 0 deletions FWCore/Framework/interface/CallbackProductResolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ namespace edm::eventsetup {
CallbackProductResolver(const CallbackProductResolver&) = delete;
const CallbackProductResolver& operator=(const CallbackProductResolver&) = delete;

unsigned int transitionID() const final { return callback_->transitionID(); }

private:
DataT data_{};
edm::propagate_const<std::shared_ptr<CallbackT>> callback_;
Expand Down
36 changes: 23 additions & 13 deletions FWCore/Framework/interface/EDConsumerBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
#include <array>
#include <cassert>
#include <tuple>
#include <utility>

// user include files
#include "DataFormats/Provenance/interface/BranchType.h"
#include "DataFormats/Provenance/interface/ProvenanceFwd.h"
#include "FWCore/Common/interface/FWCoreCommonFwd.h"
#include "FWCore/Framework/interface/ProductResolverIndexAndSkipBit.h"
Expand All @@ -37,6 +37,8 @@
#include "FWCore/Framework/interface/DataKey.h"
#include "FWCore/Framework/interface/data_default_record_trait.h"
#include "FWCore/ServiceRegistry/interface/ConsumesInfo.h"
#include "FWCore/ServiceRegistry/interface/EventSetupConsumesInfo.h"
#include "FWCore/Utilities/interface/BranchType.h"
#include "FWCore/Utilities/interface/ESIndices.h"
#include "FWCore/Utilities/interface/TypeID.h"
#include "FWCore/Utilities/interface/TypeToGet.h"
Expand Down Expand Up @@ -67,8 +69,10 @@ namespace edm {
class WillGetIfMatch;

namespace eventsetup {
struct ComponentDescription;
class ESRecordsToProductResolverIndices;
}
class EventSetupProvider;
} // namespace eventsetup

class EDConsumerBase {
public:
Expand Down Expand Up @@ -117,10 +121,16 @@ namespace edm {
std::map<std::string, ModuleDescription const*> const& labelsToDesc,
std::string const& processName) const;

void esModulesWhoseProductsAreConsumed(
eventsetup::EventSetupProvider const&,
std::array<std::vector<eventsetup::ComponentDescription const*>*,
static_cast<unsigned int>(Transition::NumberOfEventSetupTransitions)>& esModules) const;

/// Convert "@currentProcess" in InputTag process names to the actual current process name.
void convertCurrentProcessAlias(std::string const& processName);

std::vector<ConsumesInfo> consumesInfo() const;
std::vector<EventSetupConsumesInfo> eventSetupConsumesInfo(eventsetup::EventSetupProvider const&) const;

ESResolverIndex const* esGetTokenIndices(edm::Transition iTrans) const {
if (iTrans < edm::Transition::NumberOfEventSetupTransitions) {
Expand Down Expand Up @@ -288,21 +298,21 @@ namespace edm {
unsigned int m_startOfComponentName;
};

// TODO We would like to be able to access m_esTokenInfo from the
// index in the token, but this is currently not possible. One idea
// for this is to order the entries in m_esToken so that all the ones
// for transition 0 come first, then the ones for for transition 1
// and so on for all the transitions. Within a transition, the
// entries would be in the same order in m_esTokenInfo and
// esItemsToGetFromTransition_. This is something for future
// development and might require a change to SoATuple to support
// inserts in the middle of the data structure.
enum { kESLookupInfo, kESResolverIndex };
edm::SoATuple<ESTokenLookupInfo, ESResolverIndex> m_esTokenInfo;
std::array<std::vector<ESResolverIndex>, static_cast<unsigned int>(edm::Transition::NumberOfEventSetupTransitions)>
esItemsToGetFromTransition_;

using ResolverIndexContainer =
std::array<std::vector<ESResolverIndex>,
static_cast<unsigned int>(edm::Transition::NumberOfEventSetupTransitions)>;
ResolverIndexContainer esItemsToGetFromTransition_;

std::array<std::vector<ESRecordIndex>, static_cast<unsigned int>(edm::Transition::NumberOfEventSetupTransitions)>
esRecordsToGetFromTransition_;

// Ordered same as m_esTokenInfo, contents are indexes into esItemsToGetFromTransition_
std::vector<std::pair<ResolverIndexContainer::size_type, std::vector<ESResolverIndex>::size_type>>
consumesIndexToTransitionAndTokenIndex_;

bool frozen_;
bool containsCurrentProcessAlias_;
};
Expand Down
12 changes: 12 additions & 0 deletions FWCore/Framework/interface/ESProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ Example: two algorithms each creating only one objects
#include <memory>
#include <string>
#include <optional>
#include <vector>

// user include files
#include "FWCore/Framework/interface/ESConsumesCollector.h"
Expand All @@ -88,10 +89,15 @@ Example: two algorithms each creating only one objects

#include "FWCore/Framework/interface/SharedResourcesAcquirer.h"

#include "FWCore/ServiceRegistry/interface/EventSetupConsumesInfo.h"

// forward declarations
namespace edm {
namespace eventsetup {
struct ComponentDescription;
class ESRecordsToProductResolverIndices;
class EventSetupProvider;

//used by ESProducer to create the proper Decorator based on the
// argument type passed. The default it to just 'pass through'
// the argument as the decorator itself
Expand Down Expand Up @@ -154,6 +160,12 @@ namespace edm {

SerialTaskQueueChain& queue() { return acquirer_.serialQueueChain(); }

void esModulesWhoseProductsAreConsumed(eventsetup::EventSetupProvider const& eventSetupProvider,
std::vector<eventsetup::ComponentDescription const*>& esModules) const;

std::vector<std::vector<EventSetupConsumesInfo>> eventSetupConsumesInfo(
eventsetup::EventSetupProvider const& eventSetupProvider) const;

protected:
/** Specify the names of the shared resources used by this ESProducer */
void usesResources(std::vector<std::string> const&);
Expand Down
4 changes: 4 additions & 0 deletions FWCore/Framework/interface/ESProductResolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ namespace edm {

virtual void initializeForNewIOV() {}

// Counts setWhatProduced calls if creating module class derives from ESProducer.
// Currently, all others cases always return 0 (CondDBESSource, unit tests...).
virtual unsigned int transitionID() const { return 0; }

protected:
/**This is the function which does the real work of getting the data if it is not
already cached. The returning 'void const*' must point to an instance of the class
Expand Down
3 changes: 3 additions & 0 deletions FWCore/Framework/interface/EventSetupProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ namespace edm {
void fillKeys(std::set<EventSetupRecordKey>& keys) const;

EventSetupRecordProvider* tryToGetRecordProvider(const EventSetupRecordKey& iKey);
EventSetupRecordProvider const* tryToGetRecordProvider(const EventSetupRecordKey& iKey) const;

void fillAllESProductResolverProviders(std::vector<ESProductResolverProvider const*>&) const;

private:
std::shared_ptr<EventSetupRecordProvider>& recordProvider(const EventSetupRecordKey& iKey);
Expand Down
3 changes: 3 additions & 0 deletions FWCore/Framework/interface/EventSetupRecordImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ namespace edm {
void invalidateResolvers();
void resetIfTransientInResolvers();

ComponentDescription const* getComponentDescription(ESResolverIndex iResolverIndex) const;
unsigned int getTransitionID(ESResolverIndex iResolverIndex) const;

private:
void const* getFromResolverAfterPrefetch(ESResolverIndex iResolverIndex,
bool iTransientAccessOnly,
Expand Down
3 changes: 3 additions & 0 deletions FWCore/Framework/interface/EventSetupRecordProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ namespace edm {

IntervalStatus intervalStatus() const { return intervalStatus_; }

void fillAllESProductResolverProviders(std::vector<ESProductResolverProvider const*>&,
std::set<unsigned int>& componentIDs) const;

void updateLookup(ESRecordsToProductResolverIndices const&);

protected:
Expand Down
37 changes: 32 additions & 5 deletions FWCore/Framework/interface/PathsAndConsumesOfModules.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
// Created: 11/5/2014

#include "FWCore/ServiceRegistry/interface/ConsumesInfo.h"
#include "FWCore/ServiceRegistry/interface/EventSetupConsumesInfo.h"
#include "FWCore/ServiceRegistry/interface/PathsAndConsumesOfModulesBase.h"

#include "FWCore/Framework/interface/ModuleProcessName.h"
#include "FWCore/Utilities/interface/BranchType.h"
#include "FWCore/Utilities/interface/Transition.h"

#include <array>
#include <memory>
Expand All @@ -30,12 +32,19 @@ namespace edm {
class ProductRegistry;
class Schedule;

namespace eventsetup {
struct ComponentDescription;
class ESProductResolverProvider;
class EventSetupProvider;
} // namespace eventsetup

class PathsAndConsumesOfModules : public PathsAndConsumesOfModulesBase {
public:
PathsAndConsumesOfModules();
~PathsAndConsumesOfModules() override;

void initialize(Schedule const*, std::shared_ptr<ProductRegistry const>);
void initializeForEventSetup(eventsetup::EventSetupProvider const&);

void removeModules(std::vector<ModuleDescription const*> const& modules);

Expand All @@ -54,10 +63,20 @@ namespace edm {
std::vector<ModuleDescription const*> const& doModulesWhoseProductsAreConsumedBy(
unsigned int moduleID, BranchType branchType) const override;

std::vector<eventsetup::ComponentDescription const*> const& doESModulesWhoseProductsAreConsumedBy(
unsigned int moduleID, Transition) const override;

std::vector<ConsumesInfo> doConsumesInfo(unsigned int moduleID) const override;
std::vector<EventSetupConsumesInfo> doEventSetupConsumesInfo(unsigned int moduleID) const override;

unsigned int doLargestModuleID() const override;

std::vector<eventsetup::ESProductResolverProvider const*> const& doAllESProductResolverProviders() const override;
std::vector<std::vector<eventsetup::ComponentDescription const*>> const&
doESModulesWhoseProductsAreConsumedByESModule() const override;
std::vector<std::vector<EventSetupConsumesInfo>> doEventSetupConsumesInfo(
ESProducer const& esProducer) const override;

unsigned int moduleIndex(unsigned int moduleID) const;

// data members
Expand All @@ -67,17 +86,25 @@ namespace edm {

std::vector<ModuleDescription const*> allModuleDescriptions_;

std::vector<std::vector<ModuleDescription const*> > modulesOnPaths_;
std::vector<std::vector<ModuleDescription const*> > modulesOnEndPaths_;
std::vector<std::vector<ModuleDescription const*>> modulesOnPaths_;
std::vector<std::vector<ModuleDescription const*>> modulesOnEndPaths_;

// Gives a translation from the module ID to the index into the
// following data member
std::vector<std::pair<unsigned int, unsigned int> > moduleIDToIndex_;
std::vector<std::pair<unsigned int, unsigned int>> moduleIDToIndex_;

std::array<std::vector<std::vector<ModuleDescription const*>>, NumBranchTypes> modulesWhoseProductsAreConsumedBy_;
std::vector<std::vector<ModuleProcessName>> modulesInPreviousProcessesWhoseProductsAreConsumedBy_;

std::array<std::vector<std::vector<eventsetup::ComponentDescription const*>>,
static_cast<unsigned int>(Transition::NumberOfEventSetupTransitions)>
esModulesWhoseProductsAreConsumedBy_;

std::array<std::vector<std::vector<ModuleDescription const*> >, NumBranchTypes> modulesWhoseProductsAreConsumedBy_;
std::vector<std::vector<ModuleProcessName> > modulesInPreviousProcessesWhoseProductsAreConsumedBy_;
std::vector<eventsetup::ESProductResolverProvider const*> allESProductResolverProviders_;
std::vector<std::vector<eventsetup::ComponentDescription const*>> esModulesWhoseProductsAreConsumedByESModule_;

Schedule const* schedule_;
eventsetup::EventSetupProvider const* eventSetupProvider_;
std::shared_ptr<ProductRegistry const> preg_;
};

Expand Down
12 changes: 10 additions & 2 deletions FWCore/Framework/interface/Schedule.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
#include "FWCore/Utilities/interface/StreamID.h"
#include "FWCore/Utilities/interface/get_underlying_safe.h"
#include "FWCore/Utilities/interface/propagate_const.h"
#include "FWCore/Utilities/interface/Transition.h"

#include <array>
#include <map>
Expand All @@ -97,9 +98,11 @@ namespace edm {
namespace service {
class TriggerNamesService;
}
namespace evetnsetup {
namespace eventsetup {
struct ComponentDescription;
class ESRecordsToProductResolverIndices;
}
class EventSetupProvider;
} // namespace eventsetup

class BranchIDListHelper;
class EventTransitionInfo;
Expand Down Expand Up @@ -254,6 +257,11 @@ namespace edm {
std::vector<std::vector<ModuleProcessName>>& modulesInPreviousProcessesWhoseProductsAreConsumedBy,
ProductRegistry const& preg) const;

void fillESModuleAndConsumesInfo(eventsetup::EventSetupProvider const&,
std::array<std::vector<std::vector<eventsetup::ComponentDescription const*>>,
static_cast<unsigned int>(Transition::NumberOfEventSetupTransitions)>&
esModulesWhoseProductsAreConsumedBy) const;

/// Return the number of events this Schedule has tried to process
/// (inclues both successes and failures, including failures due
/// to exceptions during processing).
Expand Down
2 changes: 2 additions & 0 deletions FWCore/Framework/interface/SubProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ namespace edm {
for_all(subProcesses_, [](auto& subProcess) { subProcess.clearCounters(); });
}

void initializePathsAndConsumes();

private:
void beginJob();
void endJob(ExceptionCollector&);
Expand Down
11 changes: 10 additions & 1 deletion FWCore/Framework/interface/maker/Worker.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ the worker is reset().
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ServiceRegistry/interface/ActivityRegistry.h"
#include "FWCore/ServiceRegistry/interface/ConsumesInfo.h"
#include "FWCore/ServiceRegistry/interface/EventSetupConsumesInfo.h"
#include "FWCore/ServiceRegistry/interface/InternalContext.h"
#include "FWCore/ServiceRegistry/interface/ModuleCallingContext.h"
#include "FWCore/ServiceRegistry/interface/ParentContext.h"
Expand Down Expand Up @@ -85,8 +86,10 @@ namespace edm {
class CallImpl;
}
namespace eventsetup {
struct ComponentDescription;
class ESRecordsToProductResolverIndices;
}
class EventSetupProvider;
} // namespace eventsetup

class Worker {
public:
Expand Down Expand Up @@ -224,9 +227,15 @@ namespace edm {
ProductRegistry const& preg,
std::map<std::string, ModuleDescription const*> const& labelsToDesc) const = 0;

virtual void esModulesWhoseProductsAreConsumed(
eventsetup::EventSetupProvider const&,
std::array<std::vector<eventsetup::ComponentDescription const*>*,
static_cast<unsigned int>(Transition::NumberOfEventSetupTransitions)>& esModules) const = 0;

virtual void convertCurrentProcessAlias(std::string const& processName) = 0;

virtual std::vector<ConsumesInfo> consumesInfo() const = 0;
virtual std::vector<EventSetupConsumesInfo> eventSetupConsumesInfo(eventsetup::EventSetupProvider const&) const = 0;

virtual Types moduleType() const = 0;
virtual ConcurrencyTypes moduleConcurrencyType() const = 0;
Expand Down
19 changes: 19 additions & 0 deletions FWCore/Framework/interface/maker/WorkerT.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ WorkerT: Code common to all workers.
#include "FWCore/Framework/interface/maker/Worker.h"
#include "FWCore/Framework/interface/maker/WorkerParams.h"
#include "FWCore/ServiceRegistry/interface/ConsumesInfo.h"
#include "FWCore/ServiceRegistry/interface/EventSetupConsumesInfo.h"
#include "FWCore/Utilities/interface/BranchType.h"
#include "FWCore/Utilities/interface/propagate_const.h"
#include "FWCore/Utilities/interface/Transition.h"

#include <array>
#include <map>
Expand All @@ -29,6 +32,11 @@ namespace edm {
class ThinnedAssociationsHelper;
class WaitingTaskWithArenaHolder;

namespace eventsetup {
struct ComponentDescription;
class EventSetupProvider;
} // namespace eventsetup

template <typename T>
class WorkerT : public Worker {
public:
Expand Down Expand Up @@ -132,11 +140,22 @@ namespace edm {
modules, modulesInPreviousProcesses, preg, labelsToDesc, module_->moduleDescription().processName());
}

void esModulesWhoseProductsAreConsumed(
eventsetup::EventSetupProvider const& eventSetupProvider,
std::array<std::vector<eventsetup::ComponentDescription const*>*,
static_cast<unsigned int>(Transition::NumberOfEventSetupTransitions)>& esModules) const override {
module_->esModulesWhoseProductsAreConsumed(eventSetupProvider, esModules);
}

void convertCurrentProcessAlias(std::string const& processName) override {
module_->convertCurrentProcessAlias(processName);
}

std::vector<ConsumesInfo> consumesInfo() const override { return module_->consumesInfo(); }
std::vector<EventSetupConsumesInfo> eventSetupConsumesInfo(
eventsetup::EventSetupProvider const& eventSetupProvider) const override {
return module_->eventSetupConsumesInfo(eventSetupProvider);
}

void itemsToGet(BranchType branchType, std::vector<ProductResolverIndexAndSkipBit>& indexes) const override {
module_->itemsToGet(branchType, indexes);
Expand Down
Loading

0 comments on commit 66bc924

Please sign in to comment.