Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preprocess EDAlias and SwitchProducer information for ConditionalTask #38730

Merged
merged 1 commit into from Jul 15, 2022

Conversation

makortel
Copy link
Contributor

@makortel makortel commented Jul 13, 2022

PR description:

Profiling #38725 in https://mkortela.web.cern.ch/mkortela/cgi-bin/navigator/issue38725/hlt_ConditionalTask_06_perf/12 showed that a lot of time in an HLT job was spent in edm::ParameterSet::getParameter<edm::ParameterSet>() and edm::detail::processEDAliases(). These seemed to be caused by the processing of EDAliases and SwitchProducers for ConditionalTasks being repeated for all the Paths of the HLT menu (e.g. the SwitchProducer loop has N(paths) x N(modules) overall complexity).

This PR attempts to speed up the job startup time by processing the EDAliases and SwitchProducers for ConditionalTasks only once for all Paths, leading to > 10x improvement in the StreamSchedule constructor
https://mkortela.web.cern.ch/mkortela/cgi-bin/navigator/issue38725/hlt_ConditionalTask_36_perf/12
bringing the time close to what it would be if the HLT menu would use Tasks instead of ConditionalTasks
https://mkortela.web.cern.ch/mkortela/cgi-bin/navigator/issue38725/hlt_Task_06_perf/12

Resolves #38725

PR validation:

Framework unit tests run.

@cmsbuild
Copy link
Contributor

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-38730/31032

@cmsbuild
Copy link
Contributor

A new Pull Request was created by @makortel (Matti Kortelainen) for master.

It involves the following packages:

  • FWCore/Framework (core)

@cmsbuild, @smuzaffar, @Dr15Jones, @makortel can you please review it and eventually sign? Thanks.
@wddgit this is something you requested to watch as well.
@perrotta, @dpiparo, @qliphy, @rappoccio you are the release manager for this.

cms-bot commands are listed here

@makortel
Copy link
Contributor Author

@cmsbuild, please test

@makortel
Copy link
Contributor Author

@Dr15Jones, could you review this PR?

@cmsbuild
Copy link
Contributor

+1

Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-a95a5d/26216/summary.html
COMMIT: 12768d3
CMSSW: CMSSW_12_5_X_2022-07-13-1100/el8_amd64_gcc10
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week1/cms-sw/cmssw/38730/26216/install.sh to create a dev area with all the needed externals and cmssw changes.

Comparison Summary

Summary:

  • No significant changes to the logs found
  • Reco comparison results: 4 differences found in the comparisons
  • DQMHistoTests: Total files compared: 50
  • DQMHistoTests: Total histograms compared: 3653966
  • DQMHistoTests: Total failures: 13
  • DQMHistoTests: Total nulls: 1
  • DQMHistoTests: Total successes: 3653930
  • DQMHistoTests: Total skipped: 22
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram memory added: 0.004 KiB( 49 files compared)
  • DQMHistoSizes: changed ( 312.0 ): 0.004 KiB MessageLogger/Warnings
  • Checked 208 log files, 45 edm output root files, 50 DQM output files
  • TriggerResults: no differences found

auto const modnames = proc_pset.getParameter<vstring>(pathName);

//Pull out ConditionalTask modules
auto itCondBegin = std::find(modnames.begin(), modnames.end(), "#");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to find a way to share code between here and line 677


std::multimap<std::string, AliasInfo> const& aliasMap() const { return aliasMap_; }

std::multimap<std::string, edm::BranchDescription const*> conditionalModuleBranches(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this become a std::multimap<std::string_view, ...> to avoid possible copies? Also, what about std::multi_unordered_map?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A hurdle with the std::string_view is that the element from this is used as a key for std::unordered_map<std::string>::find(), and before C++20 that key must be std::string (with C++20 anything that can be compared against std::string would work).

switchEDAliases, allConditionalMods, proc_pset, processConfiguration.processName(), preg);
}

std::multimap<std::string, AliasInfo> aliasMap_;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about std::unordered_multimap? Tends to have a smaller footprint and runs faster.

FWCore/Framework/src/StreamSchedule.cc Show resolved Hide resolved
@@ -166,10 +292,21 @@ namespace edm {
std::vector<std::string> const& pathNames = tns.getTrigPaths();
std::vector<std::string> const& endPathNames = tns.getEndPaths();

ConditionalTaskHelper conditionalTaskHelper(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't quite remember, is the one StreamSchedule or one per stream? If the latter, then maybe ConditionalTaskHelper could be shared by them all? Depends on if workerManager_ is shared.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is indeed one StreamSchedule per stream, but each them have their own workerManager_. Maybe it/them could be shared, but it sounds like a potentially big task.

FWCore/Framework/src/StreamSchedule.cc Show resolved Hide resolved
FWCore/Framework/src/StreamSchedule.cc Show resolved Hide resolved
@makortel
Copy link
Contributor Author

+1

I'll address the review comments in a subsequent PR given the urgency mentioned in #38731 (comment).

@cmsbuild
Copy link
Contributor

This pull request is fully signed and it will be integrated in one of the next master IBs (tests are also fine). This pull request will now be reviewed by the release team before it's merged. @perrotta, @dpiparo, @qliphy, @rappoccio (and backports should be raised in the release meeting by the corresponding L2)

@qliphy
Copy link
Contributor

qliphy commented Jul 15, 2022

+1
Requested by HLT: #38731 (comment).
review comments to be addressed in a subsequent PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using ConditionalTasks make the HLT jobs take minutes to start
4 participants