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!: Reduce Seedfinder heap allocation #905

Merged
merged 18 commits into from
Aug 10, 2021

Conversation

paulgessinger
Copy link
Member

@paulgessinger paulgessinger commented Jul 30, 2021

The Seed finder does a large number of heap allocations for various different things. With this PR, I'm reducing the number of heap allocations considerably with little change to the public interface.

On my machine, the runtime of the SeedingAlgorithm on 10000 events with the generic detector drops from about 3s to 2s, for about a 33% speedup.

The number of heap allocations is reduced from 220 million to just over 300000 so about a reduction of >99%.

I checked that the estimated parameter ROOT files are identical by using our compareRootFiles.C script.

BREAKING CHANGE: The interface of a number of methods changes:

  • SeedFilter::filterSeeds_2SpFixed (takes an output iterator, is now void)
  • SeedFilter::filterSeeds_1SpFixed (takes an output iterator, is now void)
  • Seedfinder::createSeedsForGroup (takes an output iterator, is now void, takes a state object as a reference)
  • Grid::collect (returns boost::container::small_vector<size_t, N> where N = 3^DIM of the grid)

@paulgessinger paulgessinger added this to the next milestone Jul 30, 2021
@codecov
Copy link

codecov bot commented Aug 2, 2021

Codecov Report

Merging #905 (fae4e51) into main (59c0021) will increase coverage by 0.00%.
The diff coverage is 3.92%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #905   +/-   ##
=======================================
  Coverage   48.66%   48.66%           
=======================================
  Files         331      331           
  Lines       17129    17131    +2     
  Branches     8094     8092    -2     
=======================================
+ Hits         8336     8337    +1     
  Misses       3087     3087           
- Partials     5706     5707    +1     
Impacted Files Coverage Δ
Core/include/Acts/Seeding/BinFinder.ipp 0.00% <0.00%> (ø)
Core/include/Acts/Seeding/BinnedSPGroup.hpp 0.00% <0.00%> (ø)
Core/include/Acts/Seeding/Seed.hpp 0.00% <0.00%> (ø)
Core/include/Acts/Seeding/SeedFilter.hpp 0.00% <ø> (ø)
Core/include/Acts/Seeding/SeedFilter.ipp 0.00% <0.00%> (ø)
Core/include/Acts/Seeding/Seedfinder.hpp 0.00% <ø> (ø)
Core/include/Acts/Seeding/Seedfinder.ipp 0.00% <0.00%> (ø)
Core/include/Acts/Utilities/detail/grid_helper.hpp 83.65% <50.00%> (-0.33%) ⬇️

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 59c0021...fae4e51. Read the comment docs.

namespace ActsExamples {

/// A proto track is a collection of hits identified by their indices.
using ProtoTrack = std::vector<Index>;
using ProtoTrack = boost::container::small_vector<Index, 10>;
Copy link
Contributor

Choose a reason for hiding this comment

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

this uses 3x more space than necessary for 3 SP, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah true, I just went with a low-ish number. Let's see what I get with 3.

Copy link
Member Author

Choose a reason for hiding this comment

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

In my testing, reducing to 3 appears to actually slow things down by about 3%, which I can't explain. I suggest we keep it at 10.

Copy link
Contributor

@robertlangenberg robertlangenberg left a comment

Choose a reason for hiding this comment

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

The keyword for the changed interface needs to be in the PR description, right?

@paulgessinger
Copy link
Member Author

The keyword for the changed interface needs to be in the PR description, right?

Added.

@paulgessinger
Copy link
Member Author

Clang seems to dislike the template template.

@paulgessinger
Copy link
Member Author

Should compile now.

@paulgessinger paulgessinger merged commit fb99e3e into acts-project:main Aug 10, 2021
@paulgessinger paulgessinger deleted the seeding-heap-opt branch August 10, 2021 14:32
@paulgessinger paulgessinger modified the milestones: next, v11.0.0 Aug 12, 2021
stephenswat added a commit to stephenswat/acts that referenced this pull request Aug 19, 2021
This is just a tiny little improvement on acts-project#905. I noticed that we are
currently using an output iterator function to write some results to a
vector, and then copying that vector over to append it to another,
existing vector. I think it would be (very marginally) quicker and
neater to avoid this extra copy and just have the function take the
insertion iterator of the vector we are planning to write to in the end.
stephenswat added a commit to stephenswat/acts that referenced this pull request Aug 19, 2021
This is just a tiny little improvement on acts-project#905. I noticed that we are
currently using an output iterator function to write some results to a
vector, and then copying that vector over to append it to another,
existing vector. I think it would be (very marginally) quicker and
neater to avoid this extra copy and just have the function take the
insertion iterator of the vector we are planning to write to in the end.
paulgessinger pushed a commit that referenced this pull request Aug 20, 2021
This is just a tiny little improvement on #905. I noticed that we are
currently using an output iterator function to write some results to a
vector, and then copying that vector over to append it to another,
existing vector. I think it would be (very marginally) quicker and
neater to avoid this extra copy and just have the function take the
insertion iterator of the vector we are planning to write to in the end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants