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

Bring performance improvement in KDTreeLinkerAlgo as in #772 to RecoParticleFlow #26534

Merged
merged 2 commits into from
May 7, 2019
Merged

Bring performance improvement in KDTreeLinkerAlgo as in #772 to RecoParticleFlow #26534

merged 2 commits into from
May 7, 2019

Conversation

guitargeek
Copy link
Contributor

@guitargeek guitargeek commented Apr 25, 2019

PR description:

The particle flow code uses the k-d-tree data structure, which is also used in RecoPixelVertexing/PixelTriplets. It seems the pixel version was copy-pasted from PFProducer initially, but then significantly improved by @makortel in #772. Nice work!

I'm curious what would happen if we use this improved version in PFProducer, actually. If I understand #772 correctly, there should be no change in physics output, but 40 % faster searches. Maybe we can test it once to see if this is really the case and if yes do an igprof to see if we also benefit from the speedup? The obvious benefit would be to avoid double implementation, even if no speedup.

As the templated KDTreeLinkerAlgo and -Tools class is now used by two different reco packages, it was moved to CommonTools/RecoAlgos

Additional info: there seems to be another clone of the code in:
https://github.com/cms-sw/cmssw/blob/master/RecoLocalCalo/HGCalRecAlgos/interface/KDTreeLinkerAlgoT.h
https://github.com/cms-sw/cmssw/blob/master/RecoLocalCalo/HGCalRecAlgos/interface/KDTreeLinkerToolsT.h

That one is even more general, because it also has the dimension as a template. Maybe that development could also get incorporated in the new version in CommonTools/RecoAlgos, which is then used by PF, Pixel and HGCal. Note that there is also a more optimized version of a KDTree here, which got reimplemented from scratch:

https://github.com/cms-sw/cmssw/blob/master/CommonTools/RecoAlgos/interface/FKDTree.h

PR validation:

CMSSW compiles and matrix tests run.

@cmsbuild
Copy link
Contributor

The code-checks are being triggered in jenkins.

@cmsbuild
Copy link
Contributor

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-26534/9411

  • This PR adds an extra 108KB to repository

@cmsbuild
Copy link
Contributor

A new Pull Request was created by @guitargeek (Jonas Rembser) for master.

It involves the following packages:

RecoParticleFlow/PFProducer

@perrotta, @cmsbuild, @slava77 can you please review it and eventually sign? Thanks.
@mmarionncern, @hatakeyamak, @lgray, @seemasharmafnal, @cbernet, @bachtis this is something you requested to watch as well.
@davidlange6, @slava77, @fabiocos you are the release manager for this.

cms-bot commands are listed here

@slava77
Copy link
Contributor

slava77 commented Apr 25, 2019

I think that the common code should be moved to a common area.
Perhaps to CommonTools/RecoAlgos (note there is a FKDTree.h there already)

#include "RecoParticleFlow/PFProducer/interface/KDTreeLinkerTools.h"
#include "RecoParticleFlow/PFProducer/interface/KDTreeLinkerAlgo.h"
#include "RecoPixelVertexing/PixelTriplets/plugins/KDTreeLinkerAlgo.h"
#include "RecoPixelVertexing/PixelTriplets/plugins/KDTreeLinkerTools.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

cross-package includes from plugins are verboten.
I'm a bit surprised that this didn't require an update in the BuildFile.

Copy link
Contributor

@makortel makortel Apr 25, 2019

Choose a reason for hiding this comment

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

The KDTreeLinker* are header-only, so they don't create new link dependencies (but that doesn't make these includes any less verboten).

@cmsbuild
Copy link
Contributor

The code-checks are being triggered in jenkins.

@guitargeek
Copy link
Contributor Author

Yes you are right, I did this quickly and ran clang-format over the moved code.

@cmsbuild
Copy link
Contributor

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-26534/9412

  • This PR adds an extra 184KB to repository

@cmsbuild
Copy link
Contributor

Pull request #26534 was updated. @perrotta, @cmsbuild, @slava77 can you please check and sign again.

@slava77
Copy link
Contributor

slava77 commented Apr 25, 2019

hold

I think that we should wait for #26519 to be merged

@cmsbuild
Copy link
Contributor

Pull request has been put on hold by @slava77
They need to issue an unhold command to remove the hold state or L1 can unhold it for all

@cmsbuild cmsbuild added the hold label Apr 25, 2019
@slava77
Copy link
Contributor

slava77 commented Apr 25, 2019

unhold

@cmsbuild cmsbuild removed the hold label Apr 25, 2019
@slava77
Copy link
Contributor

slava77 commented Apr 25, 2019

@guitargeek
please rebase to get rid of commits from #26519.
git diff is still showing changes from those commits

@cmsbuild
Copy link
Contributor

Pull request #26534 was updated. @perrotta, @cmsbuild, @slava77 can you please check and sign again.

@perrotta
Copy link
Contributor

please test

@cmsbuild
Copy link
Contributor

cmsbuild commented Apr 26, 2019

The tests are being triggered in jenkins.
https://cmssdt.cern.ch/jenkins/job/ib-any-integration/34355/console Started: 2019/04/26 11:12

@cmsbuild
Copy link
Contributor

@cmsbuild
Copy link
Contributor

Comparison job queued.

@cmsbuild
Copy link
Contributor

Comparison is ready
https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-26534/34355/summary.html

Comparison Summary:

  • No significant changes to the logs found
  • Reco comparison results: 0 differences found in the comparisons
  • DQMHistoTests: Total files compared: 33
  • DQMHistoTests: Total histograms compared: 3211964
  • DQMHistoTests: Total failures: 1
  • DQMHistoTests: Total nulls: 0
  • DQMHistoTests: Total successes: 3211759
  • DQMHistoTests: Total skipped: 204
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram memory added: 0.0 KiB( 32 files compared)
  • Checked 137 log files, 14 edm output root files, 33 DQM output files

@perrotta
Copy link
Contributor

perrotta commented May 2, 2019

@guitargeek please let us know if you plan to profile with this PR, and verify whether the improvements in performance do correspond to what you expect, or if it has to be done in our review.

@guitargeek
Copy link
Contributor Author

Hi @perrotta, sorry I was offline in the last days. I will profile this PR today myself with IgProf and 1000 events of some Run 2 TTBar workflow and report back later.

@perrotta
Copy link
Contributor

perrotta commented May 6, 2019

Hi @perrotta, sorry I was offline in the last days. I will profile this PR today myself with IgProf and 1000 events of some Run 2 TTBar workflow and report back later.

Thank you @guitargeek
I profiled with some 100 events of wf 11024: I can see some improvement in the affected modules, but I can hardly understand whether the difference can be considered significant or not. If you are interested, I copied the outputs in /afs/cern.ch/user/a/aperrott/public/IGPROF
Maybe, if you can pinpoint better which methods in particular to look at, you can better extract a more significant info. Even, eventually, from the larger sample you are preparing.

@guitargeek
Copy link
Contributor Author

Hi, the 1000 events of step 3 in workflow 11024 are done, the igprof files can be found here:

https://rembserj.web.cern.ch/rembserj/igprof/26534/

Unfortunately, I was once again not able the generate the SQL files. I thought I had found an environment under which it reliably worked, but unfortunately I'm bothered again by
Error: near line 63: near "�gڎ�U": syntax error. I use the command from the igprof website:

igprof-analyse --sqlite -d -v -g igprof.pp.gz | sqlite3 igreport_perf.sql3

Any idea what I could do different?

Anyway, the text files are on my website and so far I can only confirm what @perrotta said before: no significant difference can be seen for the PFBlockProducer module or the entries with member functions of the KDTreeLinkgerAlgo class. This PR does not seem to affect the timing but would still be valuable to avoid code duplication.

@slava77
Copy link
Contributor

slava77 commented May 7, 2019 via email

@perrotta
Copy link
Contributor

perrotta commented May 7, 2019

+1

  • Even if not significant performance improvements are visible, this PR can avoid some code duplication by using also in PFProducer the same k-d-tree data structure already used in RecoPixelVertexing/PixelTriplets
  • Jenkins tests pass and show no difference in outputs

@cmsbuild
Copy link
Contributor

cmsbuild commented May 7, 2019

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

@fabiocos
Copy link
Contributor

fabiocos commented May 7, 2019

+1

@cmsbuild cmsbuild merged commit aec25f3 into cms-sw:master May 7, 2019
@guitargeek guitargeek deleted the PFProducer_cleanup_2 branch May 8, 2019 09:28
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