Skip to content

Commit 57670a8

Browse files
committed
Print ES module dependences from Tracer
1 parent 2e0d63c commit 57670a8

File tree

72 files changed

+2617
-556
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+2617
-556
lines changed

FWCore/Framework/interface/Callback.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ namespace edm {
4949
: Callback(iProd, std::make_shared<TProduceFunc>(std::move(iProduceFunc)), iID, iDec) {}
5050

5151
Callback* clone() {
52-
return new Callback(Base::producer(), Base::produceFunction(), Base::transitionID(), Base::decorator());
52+
return new Callback(Base::producer(), Base::produceFunction(), Base::produceMethodID(), Base::decorator());
5353
}
5454

5555
void prefetchAsync(WaitingTaskHolder iTask,

FWCore/Framework/interface/CallbackBase.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ namespace edm {
7272
producer_(iProd),
7373
callingContext_(&iProd->description(), iID),
7474
produceFunction_(std::move(iProduceFunc)),
75-
id_(iID),
75+
produceMethodID_(iID),
7676
wasCalledForThisRecord_(false),
7777
decorator_(iDec) {}
7878

@@ -133,7 +133,7 @@ namespace edm {
133133
}
134134
TRecord rec;
135135
ESParentContext pc{&context};
136-
rec.setImpl(record, transitionID(), resolvers, eventSetupImpl, &pc);
136+
rec.setImpl(record, produceMethodID(), resolvers, eventSetupImpl, &pc);
137137
ServiceRegistry::Operate operate(serviceToken.lock());
138138
record->activityRegistry()->preESModuleSignal_.emit(record->key(), context);
139139
struct EndGuard {
@@ -221,8 +221,8 @@ namespace edm {
221221
taskList_.reset();
222222
}
223223

224-
unsigned int transitionID() const noexcept { return id_; }
225-
ESResolverIndex const* getTokenIndices() const noexcept { return producer_->getTokenIndices(id_); }
224+
unsigned int produceMethodID() const noexcept { return produceMethodID_; }
225+
ESResolverIndex const* getTokenIndices() const noexcept { return producer_->getTokenIndices(produceMethodID_); }
226226

227227
std::optional<std::vector<ESResolverIndex>> const& postMayGetResolvers() const { return postMayGetResolvers_; }
228228
T* producer() noexcept { return producer_.get(); }
@@ -245,8 +245,8 @@ namespace edm {
245245
EventSetupImpl const* iImpl,
246246
ESResolverIndex const* resolvers,
247247
ServiceToken const& token) const noexcept {
248-
auto recs = producer_->getTokenRecordIndices(id_);
249-
auto n = producer_->numberOfTokenIndices(id_);
248+
auto recs = producer_->getTokenRecordIndices(produceMethodID_);
249+
auto n = producer_->numberOfTokenIndices(produceMethodID_);
250250
for (size_t i = 0; i != n; ++i) {
251251
auto rec = iImpl->findImpl(recs[i]);
252252
if (rec) {
@@ -259,8 +259,8 @@ namespace edm {
259259
//Handle mayGets
260260
TRecord rec;
261261
ESParentContext pc{&callingContext_};
262-
rec.setImpl(iRecord, transitionID(), getTokenIndices(), iEventSetupImpl, &pc);
263-
postMayGetResolvers_ = producer_->updateFromMayConsumes(id_, rec);
262+
rec.setImpl(iRecord, produceMethodID(), getTokenIndices(), iEventSetupImpl, &pc);
263+
postMayGetResolvers_ = producer_->updateFromMayConsumes(produceMethodID_, rec);
264264
return static_cast<bool>(postMayGetResolvers_);
265265
}
266266

@@ -272,8 +272,8 @@ namespace edm {
272272
// Using std::shared_ptr in order to share the state of the
273273
// functors across all clones
274274
std::shared_ptr<TProduceFunc> produceFunction_;
275-
// This transition id identifies which setWhatProduced call this Callback is associated with
276-
const unsigned int id_;
275+
// produceMethodID_ identifies which setWhatProduced call this Callback is associated with
276+
const unsigned int produceMethodID_;
277277
std::atomic<bool> wasCalledForThisRecord_;
278278
TDecorator decorator_;
279279
};

FWCore/Framework/interface/CallbackExternalWork.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ namespace edm {
9494

9595
CallbackExternalWork* clone() {
9696
return new CallbackExternalWork(
97-
Base::producer(), acquireFunction_, Base::produceFunction(), Base::transitionID(), Base::decorator());
97+
Base::producer(), acquireFunction_, Base::produceFunction(), Base::produceMethodID(), Base::decorator());
9898
}
9999

100100
void prefetchAsync(WaitingTaskHolder iTask,
@@ -177,7 +177,7 @@ namespace edm {
177177
}
178178
TRecord rec;
179179
edm::ESParentContext pc{&context};
180-
rec.setImpl(record, Base::transitionID(), resolvers, eventSetupImpl, &pc);
180+
rec.setImpl(record, Base::produceMethodID(), resolvers, eventSetupImpl, &pc);
181181
ServiceRegistry::Operate operate(serviceToken.lock());
182182
record->activityRegistry()->preESModuleAcquireSignal_.emit(record->key(), context);
183183
struct EndGuard {

FWCore/Framework/interface/CallbackProductResolver.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
// -*- C++ -*-
12
#ifndef Framework_CallbackProductResolver_h
23
#define Framework_CallbackProductResolver_h
3-
// -*- C++ -*-
44
//
55
// Package: Framework
66
// Class : CallbackProductResolver
77
//
8-
/**\class CallbackProductResolver CallbackProductResolver.h FWCore/Framework/interface/CallbackProductResolver.h
8+
/**\class edm::eventsetup::CallbackProductResolver
99
1010
Description: A ESProductResolver which performs a callback when data is requested
1111
@@ -75,6 +75,8 @@ namespace edm::eventsetup {
7575
CallbackProductResolver(const CallbackProductResolver&) = delete;
7676
const CallbackProductResolver& operator=(const CallbackProductResolver&) = delete;
7777

78+
unsigned int produceMethodID() const final { return callback_->produceMethodID(); }
79+
7880
private:
7981
DataT data_{};
8082
edm::propagate_const<std::shared_ptr<CallbackT>> callback_;

FWCore/Framework/interface/DependentRecordImplementation.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
// -*- C++ -*-
12
#ifndef FWCore_Framework_DependentRecordImplementation_h
23
#define FWCore_Framework_DependentRecordImplementation_h
3-
// -*- C++ -*-
44
//
55
// Package: Framework
66
// Class : DependentRecordImplementation
77
//
8-
/**\class DependentRecordImplementation DependentRecordImplementation.h FWCore/Framework/interface/DependentRecordImplementation.h
8+
/**\class edm::eventsetup::DependentRecordImplementation
99
1010
Description: <one line class summary>
1111

FWCore/Framework/interface/EDConsumerBase.h

Lines changed: 48 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
// -*- C++ -*-
12
#ifndef FWCore_Framework_EDConsumerBase_h
23
#define FWCore_Framework_EDConsumerBase_h
3-
// -*- C++ -*-
44
//
55
// Package: FWCore/Framework
66
// Class : EDConsumerBase
@@ -21,22 +21,24 @@
2121
// system include files
2222
#include <array>
2323
#include <map>
24+
#include <memory>
2425
#include <string>
2526
#include <vector>
2627
#include <array>
2728
#include <cassert>
2829
#include <tuple>
30+
#include <utility>
2931

3032
// user include files
31-
#include "DataFormats/Provenance/interface/BranchType.h"
3233
#include "DataFormats/Provenance/interface/ProvenanceFwd.h"
3334
#include "FWCore/Common/interface/FWCoreCommonFwd.h"
3435
#include "FWCore/Framework/interface/ProductResolverIndexAndSkipBit.h"
3536
#include "FWCore/Framework/interface/EventSetupRecordKey.h"
3637
#include "FWCore/Framework/interface/HCTypeTag.h"
3738
#include "FWCore/Framework/interface/DataKey.h"
3839
#include "FWCore/Framework/interface/data_default_record_trait.h"
39-
#include "FWCore/ServiceRegistry/interface/ConsumesInfo.h"
40+
#include "FWCore/ServiceRegistry/interface/ServiceRegistryfwd.h"
41+
#include "FWCore/Utilities/interface/BranchType.h"
4042
#include "FWCore/Utilities/interface/ESIndices.h"
4143
#include "FWCore/Utilities/interface/TypeID.h"
4244
#include "FWCore/Utilities/interface/TypeToGet.h"
@@ -67,8 +69,9 @@ namespace edm {
6769
class WillGetIfMatch;
6870

6971
namespace eventsetup {
72+
struct ComponentDescription;
7073
class ESRecordsToProductResolverIndices;
71-
}
74+
} // namespace eventsetup
7275

7376
class EDConsumerBase {
7477
public:
@@ -103,6 +106,7 @@ namespace edm {
103106
// ---------- member functions ---------------------------
104107
void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const&, bool iPrefetchMayGet);
105108
void updateLookup(eventsetup::ESRecordsToProductResolverIndices const&);
109+
void releaseMemoryPostLookupSignal();
106110
void selectInputProcessBlocks(ProductRegistry const& productRegistry,
107111
ProcessBlockHelperBase const& processBlockHelperBase) {
108112
doSelectInputProcessBlocks(productRegistry, processBlockHelperBase);
@@ -117,10 +121,15 @@ namespace edm {
117121
std::map<std::string, ModuleDescription const*> const& labelsToDesc,
118122
std::string const& processName) const;
119123

124+
void esModulesWhoseProductsAreConsumed(
125+
std::array<std::vector<eventsetup::ComponentDescription const*>*, kNumberOfEventSetupTransitions>& esModules,
126+
eventsetup::ESRecordsToProductResolverIndices const&) const;
127+
120128
/// Convert "@currentProcess" in InputTag process names to the actual current process name.
121129
void convertCurrentProcessAlias(std::string const& processName);
122130

123-
std::vector<ConsumesInfo> consumesInfo() const;
131+
std::vector<ModuleConsumesInfo> moduleConsumesInfos() const;
132+
std::vector<ModuleConsumesESInfo> moduleConsumesESInfos(eventsetup::ESRecordsToProductResolverIndices const&) const;
124133

125134
ESResolverIndex const* esGetTokenIndices(edm::Transition iTrans) const {
126135
if (iTrans < edm::Transition::NumberOfEventSetupTransitions) {
@@ -250,6 +259,31 @@ namespace edm {
250259

251260
virtual void doSelectInputProcessBlocks(ProductRegistry const&, ProcessBlockHelperBase const&);
252261

262+
struct ESTokenLookupInfo {
263+
eventsetup::EventSetupRecordKey m_record;
264+
eventsetup::DataKey m_key;
265+
unsigned int m_startOfComponentName;
266+
};
267+
268+
enum { kESLookupInfo, kESResolverIndex };
269+
270+
using ESTokenLookupInfoContainer = edm::SoATuple<ESTokenLookupInfo, ESResolverIndex>;
271+
272+
ESTokenLookupInfoContainer const& esTokenLookupInfoContainer() const {
273+
return esDataThatCanBeDeletedEarly_->esTokenLookupInfoContainer_;
274+
}
275+
276+
using ESResolverIndexContainer = std::array<std::vector<ESResolverIndex>, kNumberOfEventSetupTransitions>;
277+
278+
using ConsumesIndexConverter =
279+
std::vector<std::pair<ESResolverIndexContainer::size_type, std::vector<ESResolverIndex>::size_type>>;
280+
281+
// This can be used to convert from an index used to access esTokenLookupInfoContainer_
282+
// into the 2 indexes needed to access esItemsToGetFromTransition_
283+
ConsumesIndexConverter const& consumesIndexConverter() const {
284+
return esDataThatCanBeDeletedEarly_->consumesIndexConverter_;
285+
}
286+
253287
// ---------- member data --------------------------------
254288

255289
struct TokenLookupInfo {
@@ -282,27 +316,17 @@ namespace edm {
282316

283317
std::array<std::vector<ProductResolverIndexAndSkipBit>, edm::NumBranchTypes> itemsToGetFromBranch_;
284318

285-
struct ESTokenLookupInfo {
286-
eventsetup::EventSetupRecordKey m_record;
287-
eventsetup::DataKey m_key;
288-
unsigned int m_startOfComponentName;
319+
struct ESDataThatCanBeDeletedEarly {
320+
ESTokenLookupInfoContainer esTokenLookupInfoContainer_;
321+
ConsumesIndexConverter consumesIndexConverter_;
289322
};
290323

291-
// TODO We would like to be able to access m_esTokenInfo from the
292-
// index in the token, but this is currently not possible. One idea
293-
// for this is to order the entries in m_esToken so that all the ones
294-
// for transition 0 come first, then the ones for for transition 1
295-
// and so on for all the transitions. Within a transition, the
296-
// entries would be in the same order in m_esTokenInfo and
297-
// esItemsToGetFromTransition_. This is something for future
298-
// development and might require a change to SoATuple to support
299-
// inserts in the middle of the data structure.
300-
enum { kESLookupInfo, kESResolverIndex };
301-
edm::SoATuple<ESTokenLookupInfo, ESResolverIndex> m_esTokenInfo;
302-
std::array<std::vector<ESResolverIndex>, static_cast<unsigned int>(edm::Transition::NumberOfEventSetupTransitions)>
303-
esItemsToGetFromTransition_;
304-
std::array<std::vector<ESRecordIndex>, static_cast<unsigned int>(edm::Transition::NumberOfEventSetupTransitions)>
305-
esRecordsToGetFromTransition_;
324+
std::unique_ptr<ESDataThatCanBeDeletedEarly> esDataThatCanBeDeletedEarly_;
325+
326+
ESResolverIndexContainer esItemsToGetFromTransition_;
327+
328+
std::array<std::vector<ESRecordIndex>, kNumberOfEventSetupTransitions> esRecordsToGetFromTransition_;
329+
306330
bool frozen_;
307331
bool containsCurrentProcessAlias_;
308332
};

FWCore/Framework/interface/ESConsumesCollector.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
// -*- C++ -*-
12
#ifndef FWCore_Framework_ESConsumesCollector_h
23
#define FWCore_Framework_ESConsumesCollector_h
3-
// -*- C++ -*-
44
//
55
// Package: FWCore/Framework
66
// Class : edm::ConsumesCollector
77
//
8-
/**\class edm::ESConsumesCollector ESConsumesCollector.h "FWCore/Framework/interface/ESConsumesCollector.h"
8+
/**\class edm::ESConsumesCollector
99
1010
Description: Helper class to gather consumes information for the EventSetup.
1111
@@ -80,7 +80,7 @@ namespace edm {
8080
nullptr);
8181
//even though m_consumer may expand, the address for
8282
// name().value() remains the same since it is 'moved'.
83-
return ESGetToken<Product, Record>{m_transitionID, index, m_consumer->back().productKey_.name().value()};
83+
return ESGetToken<Product, Record>{m_produceMethodID, index, m_consumer->back().productKey_.name().value()};
8484
}
8585

8686
template <typename Product, typename Record>
@@ -91,15 +91,15 @@ namespace edm {
9191
EventSetupRecordKey::makeKey<Record>(), DataKey(DataKey::makeTypeTag<Product>(), ""), "", nullptr);
9292
//even though m_consumer may expand, the address for
9393
// name().value() remains the same since it is 'moved'.
94-
return ESGetToken<Product, Record>{m_transitionID, index, m_consumer->back().productKey_.name().value()};
94+
return ESGetToken<Product, Record>{m_produceMethodID, index, m_consumer->back().productKey_.name().value()};
9595
}
9696

9797
ESConsumesCollectorAdaptor consumes();
9898
ESConsumesCollectorWithTagAdaptor consumes(ESInputTag tag);
9999

100100
protected:
101-
explicit ESConsumesCollector(ESConsumesInfo* const iConsumer, unsigned int iTransitionID)
102-
: m_consumer{iConsumer}, m_transitionID{iTransitionID} {}
101+
explicit ESConsumesCollector(ESConsumesInfo* const iConsumer, unsigned int iProduceMethodID)
102+
: m_consumer{iConsumer}, m_produceMethodID{iProduceMethodID} {}
103103

104104
template <typename Product, typename Record, typename Collector, typename PTag>
105105
auto registerMayConsume(std::unique_ptr<Collector> iCollector, PTag const& productTag) {
@@ -115,13 +115,13 @@ namespace edm {
115115
std::move(iCollector));
116116
//even though m_consumer may expand, the address for
117117
// name().value() remains the same since it is 'moved'.
118-
return ESGetToken<Product, Record>{m_transitionID, index, m_consumer->back().productKey_.name().value()};
118+
return ESGetToken<Product, Record>{m_produceMethodID, index, m_consumer->back().productKey_.name().value()};
119119
}
120120

121121
private:
122122
// ---------- member data --------------------------------
123123
edm::propagate_const<ESConsumesInfo*> m_consumer{nullptr};
124-
unsigned int m_transitionID{0};
124+
unsigned int m_produceMethodID{0};
125125
};
126126

127127
template <typename RECORD>

FWCore/Framework/interface/ESProducer.h

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ Example: two algorithms each creating only one objects
7272
#include <memory>
7373
#include <string>
7474
#include <optional>
75+
#include <vector>
7576

7677
// user include files
7778
#include "FWCore/Framework/interface/ESConsumesCollector.h"
@@ -87,11 +88,14 @@ Example: two algorithms each creating only one objects
8788
#include "FWCore/Framework/interface/es_Label.h"
8889

8990
#include "FWCore/Framework/interface/SharedResourcesAcquirer.h"
91+
#include "FWCore/ServiceRegistry/interface/ServiceRegistryfwd.h"
9092

9193
// forward declarations
9294
namespace edm {
9395
namespace eventsetup {
96+
struct ComponentDescription;
9497
class ESRecordsToProductResolverIndices;
98+
9599
//used by ESProducer to create the proper Decorator based on the
96100
// argument type passed. The default it to just 'pass through'
97101
// the argument as the decorator itself
@@ -154,6 +158,12 @@ namespace edm {
154158

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

161+
void esModulesWhoseProductsAreConsumed(std::vector<eventsetup::ComponentDescription const*>& esModules,
162+
eventsetup::ESRecordsToProductResolverIndices const&) const;
163+
164+
std::vector<std::vector<ESModuleConsumesInfo>> esModuleConsumesInfos(
165+
eventsetup::ESRecordsToProductResolverIndices const&) const;
166+
157167
protected:
158168
/** Specify the names of the shared resources used by this ESProducer */
159169
void usesResources(std::vector<std::string> const&);
@@ -226,18 +236,19 @@ namespace edm {
226236

227237
template <typename TReturn, typename TRecord, typename TFunc, typename TDecorator>
228238
ESConsumesCollectorT<TRecord> setWhatProduced(TFunc&& func, TDecorator&& iDec, const es::Label& iLabel = {}) {
229-
const auto id = consumesInfoSize();
239+
const auto produceMethodID = consumesInfoSize();
230240
using DecoratorType = std::decay_t<TDecorator>;
231241
using CallbackType = eventsetup::Callback<ESProducer, TFunc, TReturn, TRecord, DecoratorType>;
232242
unsigned int iovIndex = 0; // Start with 0, but later will cycle through all of them
233-
auto temp = std::make_shared<CallbackType>(this, std::forward<TFunc>(func), id, std::forward<TDecorator>(iDec));
243+
auto temp = std::make_shared<CallbackType>(
244+
this, std::forward<TFunc>(func), produceMethodID, std::forward<TDecorator>(iDec));
234245
auto callback =
235246
std::make_shared<std::pair<unsigned int, std::shared_ptr<CallbackType>>>(iovIndex, std::move(temp));
236247
registerProducts(std::move(callback),
237248
static_cast<const typename eventsetup::produce::product_traits<TReturn>::type*>(nullptr),
238249
static_cast<const TRecord*>(nullptr),
239250
iLabel);
240-
return ESConsumesCollectorT<TRecord>(consumesInfoPushBackNew(), id);
251+
return ESConsumesCollectorT<TRecord>(consumesInfoPushBackNew(), produceMethodID);
241252
}
242253

243254
// These next four functions are intended for use in this class and

FWCore/Framework/interface/ESProductResolver.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ namespace edm {
7171

7272
virtual void initializeForNewIOV() {}
7373

74+
// Counts setWhatProduced calls if creating module class derives from ESProducer.
75+
// Currently, all others cases always return 0 (CondDBESSource, unit tests...).
76+
virtual unsigned int produceMethodID() const;
77+
7478
protected:
7579
/**This is the function which does the real work of getting the data if it is not
7680
already cached. The returning 'void const*' must point to an instance of the class

0 commit comments

Comments
 (0)