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

perf: Use map to accelerate parameter estimator #952

Merged

Conversation

stephenswat
Copy link
Member

While I was playing around with the seeding, I noticed that the TrackParamsEstimationAlgorithm was a significant source of overhead for high pile-up events. When processing events with 4000 pions, the time taken to run this algorithm starts to approach the runtime of seeding itself. For much larger events, in the neighbourhood of 12000 pions (where we get higher fake rates), the result was even worse with the track parameter estimation taking hundreds of milliseconds. The reason for this is simple: given |S| spacepoints (which in itself linear in the number of particles), the track parameter estimation performs an O(|S|) lookup operation for each of the O(1) hits in each seed. In total, there are O(|S|) (or even O(|S|3) in the uncapped case) seeds, and so the track parameter estimation is a somewhat expensive O(|S|2) algorithm.

In this commit, I replace the O(|S|) lookup operation by an equivalent O(log |S|) operation permitted by std::map. This reduces the overall complexity to O(|S| log |S|), providing a significant speed-up. For the previously mentioned 12000 pion events, the processing time of this specific algorithm on my laptop drops from 259 milliseconds to 21 milliseconds: a speed-up of a factor twelve.

@stephenswat stephenswat added this to the next milestone Aug 19, 2021
@stephenswat stephenswat added Component - Examples Affects the Examples module Improvement Changes to an existing feature Impact - Minor Nuissance bug and/or affects only a single module labels Aug 19, 2021
While I was playing around with the seeding, I noticed that the
`TrackParamsEstimationAlgorithm` was a significant source of overhead
for high pile-up events. When processing events with 4000 pions, the
time taken to run this algorithm starts to approach the runtime of
seeding itself. For much larger events, in the neighbourhood of
12000 pions (where we get higher fake rates), the result was even worse
with the track parameter estimation taking hundreds of milliseconds. The
reason for this is simple: given |S| spacepoints (which in itself linear
in the number of particles), the track parameter estimation performs an
O(|S|) lookup operation for each of the O(1) hits in each seed. In
total, there are O(|S|) (or even O(|S|^3) in the uncapped case) seeds,
and so the track parameter estimation is a somewhat expensive O(|S|^2)
algorithm.

In this commit, I replace the O(|S|) lookup operation by an equivalent
O(1) operation permitted by `std::unordered_map`. This reduces the
overall complexity to O(|S|), providing a significant speed-up.  For the
previously mentioned 12000 pion events, the processing time of this
specific algorithm on my laptop drops from 259 milliseconds to 14
milliseconds: a speed-up of a factor nineteen.
@stephenswat stephenswat force-pushed the perf/track_param_estimator_map branch from 68bbb47 to c18258c Compare August 19, 2021 11:55
@codecov
Copy link

codecov bot commented Aug 19, 2021

Codecov Report

Merging #952 (c18258c) into main (60c824c) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #952   +/-   ##
=======================================
  Coverage   48.62%   48.62%           
=======================================
  Files         334      334           
  Lines       17152    17152           
  Branches     8087     8087           
=======================================
  Hits         8340     8340           
  Misses       3094     3094           
  Partials     5718     5718           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 60c824c...c18258c. Read the comment docs.

Copy link
Member

@paulgessinger paulgessinger left a comment

Choose a reason for hiding this comment

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

LGTM

@paulgessinger paulgessinger merged commit d74d411 into acts-project:main Aug 19, 2021
@paulgessinger paulgessinger modified the milestones: next, v12.0.0 Aug 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component - Examples Affects the Examples module Impact - Minor Nuissance bug and/or affects only a single module Improvement Changes to an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants