@@ -364,23 +364,39 @@ namespace edm::service::moduleAlloc {
364364
365365 auto beginTime = TimingServiceBase::jobStartTime ();
366366
367+ auto esModuleCtrDtrPtr = std::make_shared<std::vector<ModuleCtrDtr>>();
368+ auto & esModuleCtrDtr = *esModuleCtrDtrPtr;
367369 auto esModuleLabelsPtr = std::make_shared<std::vector<std::string>>();
368370 auto & esModuleLabels = *esModuleLabelsPtr;
369371 auto esModuleTypesPtr = std::make_shared<std::vector<std::string>>();
370372 auto & esModuleTypes = *esModuleTypesPtr;
371373 // acquire names for all the ED and ES modules
372- iRegistry.watchPostESModuleRegistration ([&esModuleLabels, &esModuleTypes](auto const & iDescription) {
373- if (esModuleLabels.size () <= iDescription.id_ + 1 ) {
374- esModuleLabels.resize (iDescription.id_ + 2 );
375- esModuleTypes.resize (iDescription.id_ + 2 );
376- }
377- // NOTE: we want the id to start at 1 not 0
378- if (not iDescription.label_ .empty ()) {
379- esModuleLabels[iDescription.id_ + 1 ] = iDescription.label_ ;
380- } else {
381- esModuleLabels[iDescription.id_ + 1 ] = iDescription.type_ ;
374+ iRegistry.watchPreESModuleConstruction (
375+ [&esModuleLabels, &esModuleTypes, &esModuleCtrDtr, beginTime, iFilter](auto const & iDescription) {
376+ auto const t = duration_cast<duration_t >(now () - beginTime).count ();
377+ auto const mid = iDescription.id_ + 1 ; // NOTE: we want the id to start at 1 not 0
378+ if (esModuleLabels.size () <= mid) {
379+ esModuleLabels.resize (mid + 1 );
380+ esModuleTypes.resize (mid + 1 );
381+ esModuleCtrDtr.resize (mid + 1 );
382+ }
383+ if (not iDescription.label_ .empty ()) {
384+ esModuleLabels[mid] = iDescription.label_ ;
385+ } else {
386+ esModuleLabels[mid] = iDescription.type_ ;
387+ }
388+ esModuleTypes[mid] = iDescription.type_ ;
389+ esModuleCtrDtr.back ().beginConstruction = t;
390+ iFilter->startOnThread (-1 * mid);
391+ });
392+ iRegistry.watchPostESModuleConstruction ([&esModuleCtrDtr, beginTime, iFilter](auto const & md) {
393+ auto const t = duration_cast<duration_t >(now () - beginTime).count ();
394+ auto const mid = md.id_ + 1 ;
395+ esModuleCtrDtr[mid].endConstruction = t;
396+ auto alloc = iFilter->stopOnThread (-1 * mid);
397+ if (alloc) {
398+ esModuleCtrDtr[mid].constructionAllocInfo = *alloc;
382399 }
383- esModuleTypes[iDescription.id_ + 1 ] = iDescription.type_ ;
384400 });
385401 auto moduleCtrDtrPtr = std::make_shared<std::vector<ModuleCtrDtr>>();
386402 auto & moduleCtrDtr = *moduleCtrDtrPtr;
@@ -498,6 +514,7 @@ namespace edm::service::moduleAlloc {
498514 esModuleLabelsPtr,
499515 esModuleTypesPtr,
500516 moduleCtrDtrPtr,
517+ esModuleCtrDtrPtr,
501518 sourceCtrPtr,
502519 sourceTypePtr = std::move (sourceTypePtr),
503520 beginTime,
@@ -541,6 +558,35 @@ namespace edm::service::moduleAlloc {
541558 logFile->write (std::move (msg));
542559 return ;
543560 }
561+ {
562+ std::vector<int > indices (esModuleCtrDtrPtr->size ());
563+ std::iota (indices.begin (), indices.end (), 0 );
564+ std::sort (indices.begin (), indices.end (), [&esModuleCtrDtrPtr](int l, int r) {
565+ return (*esModuleCtrDtrPtr)[l].beginConstruction < (*esModuleCtrDtrPtr)[r].beginConstruction ;
566+ });
567+ for (auto index : indices) {
568+ if (not iFilter->keepModuleInfo (-1 * index)) {
569+ continue ;
570+ }
571+ auto const & ctr = (*esModuleCtrDtrPtr)[index];
572+ if (ctr.beginConstruction != 0 and ctr.endConstruction != 0 ) {
573+ auto msg = assembleMessage<Step::preESModule>(
574+ static_cast <std::underlying_type_t <Phase>>(Phase::construction), 0 , index, 0 , 0 , ctr.beginConstruction );
575+ logFile->write (std::move (msg));
576+ auto emsg = assembleAllocMessage<Step::postESModule>(
577+ ctr.constructionAllocInfo ,
578+ static_cast <std::underlying_type_t <Phase>>(Phase::construction),
579+ 0 ,
580+ index,
581+ 0 ,
582+ 0 ,
583+ ctr.endConstruction );
584+ logFile->write (std::move (emsg));
585+ ++index;
586+ }
587+ }
588+ }
589+
544590 // NOTE: the source construction can run concurently with module construction so we need to properly
545591 // interleave its timing in with the modules
546592 auto srcBeginConstruction = sourceCtrPtr->beginConstruction ;
0 commit comments