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

Allow caching of HFShowerLibrary #40278

Merged
merged 11 commits into from
Dec 12, 2022
Merged

Conversation

Dr15Jones
Copy link
Contributor

PR description:

  • Modernized code related to HFShowerLibrary
  • decreased memory size of HFShowerPhoton by remove unnecessary virtualization
  • Added ability to cache entire contents of HFShowerLibrary file and share it safely across instances of modules. (Ability is off by default).

PR validation:

  • Added a unit test for HFShowerLibrary to show with and without caching give same results. Test also shows that all three existing data files can be read without errors.
  • Ran demonstrator which produces pileup files by running the GEN+SIM step for the minimum bias within the mixing module. This generated around 80,000 min bias per job (800 minibias/event with 100 events) using 8 threads without issues.

Comparing timing with and without caching showed a 1-2% speed improvement when using caching.

- removed virtual destructor to save 12 bytes of space when stored in
 a contiguous container.
- explicitly have compiler create default constructor/operator=
- improved const correctness
- moved member data which was only used as temporary storage to be
  function local variables (done in other classes as well).
- encapsulate message logger calls within the log member function
- made member data names conform to CMS standards
- added unit tests
- hold onto HFFibre directly, not via unique_ptr
- modified HFShowerLibrary to be easier to test by removing
  dependencies on conditions classes.
Use a helper class to manage the TBranch and how to read it back
properly based on the file format.
The ability is off by default. The data can be safely shared by
all HFShowerLibrary instances in a job.
@Dr15Jones
Copy link
Contributor Author

please test

@cmsbuild
Copy link
Contributor

cmsbuild commented Dec 9, 2022

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-40278/33330

  • This PR adds an extra 60KB to repository

@cmsbuild
Copy link
Contributor

cmsbuild commented Dec 9, 2022

A new Pull Request was created by @Dr15Jones (Chris Jones) for master.

It involves the following packages:

  • SimDataFormats/CaloHit (simulation)
  • SimG4CMS/Calo (simulation)

@civanch, @mdhildreth can you please review it and eventually sign? Thanks.
@youyingli, @lecriste, @apsallid, @felicepantaleo, @rovere, @missirol, @bsunanda, @thomreis, @simonepigazzini, @fabiocos, @slomeo this is something you requested to watch as well.
@perrotta, @dpiparo, @rappoccio you are the release manager for this.

cms-bot commands are listed here

const HcalSimulationParameters* hps,
edm::ParameterSet const& p);
~HFFibre() = default;
HFFibre(const HcalDDDSimConstants* hcons, const HcalSimulationParameters* hps, edm::ParameterSet const& p);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The name was not used.

std::array<double, 2> lambdaLimits_;
};

HFFibre(Params iP);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This helps with testing as one doesn't have to create a ParameterSet in order to setup the class.


private:
const HcalDDDSimConstants* hcalConstant_;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed variables were only used during construction so did not have to be kept around.

int fileVersion_;
bool cacheBranches_ = false;
};
HFShowerLibrary(Params const &, FileParams const &, HFFibre::Params);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Helps with testing.

[[nodiscard]] HFShowerPhotonCollection getRecord(int) const;

private:
HFShowerPhotonCollection photons_;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Photons for all entries are stored in the same collection in order to avoid overhead of many individual std::vector<>s. To find the entries one consults offsets_.

ss1 << "\n";
nBinAtt_ = static_cast<int>(attL_.size());

edm::LogVerbatim("HFShower").log([&](auto& logger) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

LogVerbatim::log will only call the lambda if the message will potentially be sent. This avoids building the std::stringstream only to have its contents thrown away.

const HcalSimulationParameters* hps,
edm::ParameterSet const& hfShower,
edm::ParameterSet const& hfShowerLibrary)
: HFShowerLibrary(paramsFrom(hfShower, hfShowerLibrary, hcons->getPhiTableHF().front()),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Having a constructor that takes the two different ParameterSets allowed those values to be passed to two different functions without having to call getParameterSet several times.

if (nRecords > maxRecordsToCache) {
nRecords = maxRecordsToCache;
}
offsets_.reserve(nRecords + 1);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

offsets_[0+record] returns the starting element in photons_ to read while offsets_[1+record] gives one passed the end. Hence why we need 1 more element.


void HFShowerLibrary::getRecord(int type, int record) {
HFShowerPhotonCollection HFShowerLibrary::BranchReader::getRecordOldForm(TBranch* iBranch, int iEntry) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved handling of the different file formats into their own functions.

@cmsbuild
Copy link
Contributor

cmsbuild commented Dec 9, 2022

+1

Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-9fae6b/29549/summary.html
COMMIT: caf555f
CMSSW: CMSSW_13_0_X_2022-12-09-1100/el8_amd64_gcc11
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week0/cms-sw/cmssw/40278/29549/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: 8 differences found in the comparisons
  • DQMHistoTests: Total files compared: 48
  • DQMHistoTests: Total histograms compared: 3421510
  • DQMHistoTests: Total failures: 6
  • DQMHistoTests: Total nulls: 0
  • DQMHistoTests: Total successes: 3421482
  • DQMHistoTests: Total skipped: 22
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram memory added: 0.0 KiB( 47 files compared)
  • Checked 206 log files, 158 edm output root files, 48 DQM output files
  • TriggerResults: no differences found

@civanch
Copy link
Contributor

civanch commented Dec 10, 2022

+1

For this type of modification regression means that nothing changed for Run2 and Run3. Class organisation is improved.

@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, @rappoccio (and backports should be raised in the release meeting by the corresponding L2)

@perrotta
Copy link
Contributor

+1

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.

4 participants