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

mitigate high CPU cost of HBHE hit position calculation in EgammaHcalIsolation #35955

Merged
merged 2 commits into from Nov 3, 2021

Conversation

slava77
Copy link
Contributor

@slava77 slava77 commented Nov 2, 2021

costs of computing HCAL isolation in egamma has increased significantly after #33666

This PR mitigates the situation by reordering the calls.

However, a better refactoring of the code should be considered in near future. Some options are

  • accumulate all needed isolation types in one loop over rechits
  • precompute (η,φ) of rechits in a separate producer in a ValueMap and use it when dR computations are needed
    @wrtabb @SohamBhattacharya

@cmsbuild cmsbuild added this to the CMSSW_12_2_X milestone Nov 2, 2021
@slava77 slava77 changed the title mitigate high CPU cost of HBHE hit position calculation mitigate high CPU cost of HBHE hit position calculation in EgammaHcalIsolation Nov 2, 2021
@slava77
Copy link
Contributor Author

slava77 commented Nov 2, 2021

enable profiling

@cmsbuild
Copy link
Contributor

cmsbuild commented Nov 2, 2021

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-35955/26365

  • This PR adds an extra 12KB to repository

@slava77
Copy link
Contributor Author

slava77 commented Nov 2, 2021

@cmsbuild please test

@cmsbuild
Copy link
Contributor

cmsbuild commented Nov 2, 2021

A new Pull Request was created by @slava77 (Slava Krutelyov) for master.

It involves the following packages:

  • RecoEgamma/EgammaIsolationAlgos (reconstruction)

@jpata, @slava77 can you please review it and eventually sign? Thanks.
@Sam-Harper, @jainshilpi, @lgray, @sobhatta, @afiqaize, @wrtabb, @varuns23, @ram1123 this is something you requested to watch as well.
@perrotta, @dpiparo, @qliphy you are the release manager for this.

cms-bot commands are listed here

@cmsbuild
Copy link
Contributor

cmsbuild commented Nov 2, 2021

+1

Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-0b0595/20187/summary.html
COMMIT: b00003d
CMSSW: CMSSW_12_2_X_2021-11-02-1100/slc7_amd64_gcc900
Additional Tests: PROFILING
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week1/cms-sw/cmssw/35955/20187/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: 0 differences found in the comparisons
  • DQMHistoTests: Total files compared: 42
  • DQMHistoTests: Total histograms compared: 2901890
  • DQMHistoTests: Total failures: 0
  • DQMHistoTests: Total nulls: 0
  • DQMHistoTests: Total successes: 2901868
  • DQMHistoTests: Total skipped: 22
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram memory added: 0.0 KiB( 41 files compared)
  • Checked 177 log files, 37 edm output root files, 42 DQM output files
  • TriggerResults: no differences found

@slava77
Copy link
Contributor Author

slava77 commented Nov 2, 2021

in IB igprof tests the perf counts in EgammaHcalIsolation::getHcalSum have reduced by about a factor of 7

This is roughly expected from the early return after the depth check (7 depths are checked).

@cmsbuild
Copy link
Contributor

cmsbuild commented Nov 3, 2021

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-35955/26386

  • This PR adds an extra 16KB to repository

@slava77
Copy link
Contributor Author

slava77 commented Nov 3, 2021

@cmsbuild please test

@cmsbuild
Copy link
Contributor

cmsbuild commented Nov 3, 2021

Pull request #35955 was updated. @jpata, @slava77 can you please check and sign again.

@swagata87
Copy link
Contributor

thank you Slava,
this will be very useful for EGM HLT also

@cmsbuild
Copy link
Contributor

cmsbuild commented Nov 3, 2021

+1

Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-0b0595/20209/summary.html
COMMIT: f33bdaa
CMSSW: CMSSW_12_2_X_2021-11-02-1100/slc7_amd64_gcc900
Additional Tests: PROFILING
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week1/cms-sw/cmssw/35955/20209/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: 42
  • DQMHistoTests: Total histograms compared: 2901890
  • DQMHistoTests: Total failures: 6
  • DQMHistoTests: Total nulls: 0
  • DQMHistoTests: Total successes: 2901862
  • DQMHistoTests: Total skipped: 22
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram memory added: 0.0 KiB( 41 files compared)
  • Checked 177 log files, 37 edm output root files, 42 DQM output files
  • TriggerResults: no differences found

@slava77
Copy link
Contributor Author

slava77 commented Nov 3, 2021

thank you Slava, this will be very useful for EGM HLT also

does this imply a backport?
If so, to which release?

@slava77
Copy link
Contributor Author

slava77 commented Nov 3, 2021

in IB igprof tests the perf counts in EgammaHcalIsolation::getHcalSum have reduced by about a factor of 7

This is roughly expected from the early return after the depth check (7 depths are checked).

the last update now has

So, slightly more than a factor of 8 speedup.

I think that further speedup is possible by refactoring the calling code. I added #35969 to track further progress with this still somewhat heavy code.

@slava77
Copy link
Contributor Author

slava77 commented Nov 3, 2021

+reconstruction

for #35955 f33bdaa

  • code changes are technical, as confirmed by the PR comparisons/tests

@cmsbuild
Copy link
Contributor

cmsbuild commented Nov 3, 2021

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

@perrotta
Copy link
Contributor

perrotta commented Nov 3, 2021

+1

@cmsbuild cmsbuild merged commit 69ae98c into cms-sw:master Nov 3, 2021
@swagata87
Copy link
Contributor

does this imply a backport? If so, to which release?

no, I don't think a backport is needed

return 0.;

const auto phit = caloGeometry_.getPosition(hit.detid());
const float phitEta = phit.eta();
Copy link
Contributor

Choose a reason for hiding this comment

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

use cashed eta in caloGeometry_

Copy link
Contributor Author

Choose a reason for hiding this comment

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

please clarify the member method
Geometry/CaloGeometry/interface/CaloGeometry.h has only xyz position

Copy link
Contributor

Choose a reason for hiding this comment

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

RhoEtaPhi const& repPos() const { return m_rep; }
virtual float rhoPos() const { return m_rep.rho(); }
virtual float etaPos() const { return m_rep.eta(); }
virtual float phiPos() const { return m_rep.phi(); }

Copy link
Contributor

Choose a reason for hiding this comment

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

eventually through CaloGeometry::getGeometry if not in the same SubDetector

Copy link
Contributor

Choose a reason for hiding this comment

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

one could extend the CaloGeometry interface to support repPos (copy paste code of getPosition)
In my opinion would be more efficient to check first if the CellGeometry is the same and avoid the overhead of the code (not inlined) to search for the subDetector for each single hit....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah, so the suggestion is for an extension to the geometry interface; I thought at first that this is something that exists already.

IIRC, there is one rechit per cell in ECAL/HCAL

Copy link
Contributor

@VinInn VinInn Nov 12, 2021

Choose a reason for hiding this comment

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

it exits already in CaloCellGeometry that is what CaloGeometry access. please have a look to the implementation in
https://cmssdt.cern.ch/dxr/CMSSW/source/Geometry/CaloGeometry/src/CaloGeometry.cc#50
here locally one can invoke
caloGeometry_.getGeometry(hit.detid())->repPos();

Copy link
Contributor

@VinInn VinInn Nov 12, 2021

Choose a reason for hiding this comment

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

here https://github.com/slava77/cmssw/blob/f33bdaa8be9c4aa4a3f336dbf23501b059a8988b/RecoEgamma/EgammaIsolationAlgos/src/EgammaHcalIsolation.cc#L188
thre is a loop on the hits in HBorHE. one can verify if a hit is in the same SubDet of the previous one and avoid all the search logic in CaloGeometry and acess directly CaloCellGeometry

const float phitEta = phit.eta();

if (extIncRule_ == InclusionRule::withinConeAroundCluster or intIncRule_ == InclusionRule::withinConeAroundCluster) {
auto const dR2 = deltaR2(pcluEta, pcluPhi, phitEta, phit.phi());
Copy link
Contributor

Choose a reason for hiding this comment

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

use cashed phi in caloGeometry

if (!(goodHBe or goodHEe))
return 0.;

const auto phit = caloGeometry_.getPosition(hit.detid());
Copy link
Contributor

@VinInn VinInn Nov 12, 2021

Choose a reason for hiding this comment

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

suggested change:

auto const & phit = caloGeometry_.getGeometry(hit.detid())->repPos();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

suggested change:

Thanks. Testing.
PR soon.

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.

None yet

6 participants