33 static void startOnThread() { threadAllocInfo().reset(); }
35 auto&
t = threadAllocInfo();
49 void allocCalled(
size_t iRequested,
size_t iActual)
final {
50 auto& allocInfo = threadAllocInfo();
51 if (not allocInfo.active_) {
54 allocInfo.nAllocations_ += 1;
55 allocInfo.requested_ += iRequested;
57 if (allocInfo.maxSingleAlloc_ < iRequested) {
58 allocInfo.maxSingleAlloc_ = iRequested;
61 allocInfo.presentActual_ += iActual;
62 if (allocInfo.presentActual_ > static_cast<long long>(allocInfo.maxActual_)) {
63 allocInfo.maxActual_ = allocInfo.presentActual_;
66 void deallocCalled(
size_t iActual)
final {
67 auto& allocInfo = threadAllocInfo();
68 if (not allocInfo.active_) {
72 allocInfo.nDeallocations_ += 1;
73 allocInfo.presentActual_ -= iActual;
74 if (allocInfo.presentActual_ < 0) {
75 if (allocInfo.minActual_ == 0
or allocInfo.minActual_ > allocInfo.presentActual_) {
76 allocInfo.minActual_ = allocInfo.presentActual_;
92 MonitorAdaptor::startOnThread();
104 return &MonitorAdaptor::stopOnThread();
113 MonitorAdaptor::startOnThread();
121 return &MonitorAdaptor::stopOnThread();
139 nEventsToSkip_(iPS.getUntrackedParameter<unsigned
int>(
"nEventsToSkip")),
140 filter_(&moduleIDs_) {
143 if (nEventsToSkip_ > 0) {
144 filter_.setGlobalKeep(
false);
146 if (not moduleNames_.empty()) {
149 if (
found != moduleNames_.end()) {
151 std::sort(moduleIDs_.begin(), moduleIDs_.end());
156 auto label = iDescription.label_;
158 label = iDescription.type_;
161 if (
found != moduleNames_.end()) {
163 moduleIDs_.push_back(-1 * (iDescription.id_ + 1));
164 std::sort(moduleIDs_.begin(), moduleIDs_.end());
168 if (nEventsToSkip_ > 0) {
171 if (nEventsStarted_ > nEventsToSkip_) {
172 filter_.setGlobalKeep(
true);
182 ps.
addUntracked<std::vector<std::string>>(
"moduleNames", std::vector<std::string>());
189 return (moduleNames_.empty()
or std::binary_search(moduleIDs_.begin(), moduleIDs_.end(), iID));
193 unsigned int nEventsToSkip_ = 0;
194 std::atomic<unsigned int> nEventsStarted_{0};
void watchPostESModuleRegistration(PostESModuleRegistration::slot_type const &iSlot)
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void watchPreModuleConstruction(PreModuleConstruction::slot_type const &iSlot)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
const ThreadAllocInfo * stopOnThread() const
bool startOnThread() const
TEMPL(T2) struct Divides void
std::atomic< bool > globalKeep_
T getUntrackedParameter(std::string const &, T const &) const
bool forThisModule(unsigned int iID)
Filter(std::vector< int > const *moduleIDs)
void setupFile(std::string const &iFileName, edm::ActivityRegistry &iRegistry, Filter const *iFilter)
void addDefault(ParameterSetDescription const &psetDescription)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
edm::service::moduleAlloc::Filter filter_
std::vector< int > moduleIDs_
bool keepModuleInfo(int moduleID) const
std::vector< std::string > moduleNames_
void setGlobalKeep(bool iShouldKeep)
#define DEFINE_FWK_SERVICE(type)
std::vector< int > const * moduleIDs_
void watchPreSourceEvent(PreSourceEvent::slot_type const &iSlot)
ModuleAllocMonitor(edm::ParameterSet const &iPS, edm::ActivityRegistry &iAR)
static void fillDescriptions(edm::ConfigurationDescriptions &iDesc)