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

refactor: Reuse MultiTrajectory in (C)KF #1507

Merged
merged 9 commits into from
Sep 13, 2022

Conversation

paulgessinger
Copy link
Member

@paulgessinger paulgessinger commented Sep 12, 2022

This PR changes the CKF and KF to reuse the same MultiTrajectory. CKF does this internally, retaining a single MTJ outside the for loop over the seeds. KF's fit() method now accepts an optional trajectory argument, that it will append track states into. If it's not given, it will create a fresh MTJ.

This cuts down on the number of objects we have flying around.

In the post-processing of CKF outputs via Trajectory objects, all of the objects per event will now point to the same MTJ. I plan to refactor this when the Track EDM lands.

See #1516

@paulgessinger paulgessinger added this to the next milestone Sep 12, 2022
Copy link
Member

@benjaminhuth benjaminhuth left a comment

Choose a reason for hiding this comment

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

Looks good to me! Very straight forward changes, nothing I want to comment on...

Just out of curiosity: Do you have measured if this has a performance impact?

@paulgessinger
Copy link
Member Author

@benjaminhuth No I haven't but that's actually a good point.

@paulgessinger
Copy link
Member Author

I ran KF, CKF and GSF examples to get a rough idea of the performance:

Example main feat events
ckf 6.287 +- 0.037s 6.047 +- 0.076s 1250
kf 5.834 +- 0.017s 5.752 +- 0.037s 15000
gsf 5.978 +- 0.035s 6.598 +- 0.020s 100

It seems CKF and KF are slightly faster, while GSF gets substantially slower. This is average + stdev of 10 runs each.

@benjaminhuth Any idea why this change might be affecting GSF differently than (C)KF? Overhead from shared_ptr copies?

@paulgessinger
Copy link
Member Author

Ok I think I managed to bring down the GSF example runtime on this branch to something like 6.043 +- 0.018s by lifting where it resolves if an input trajectory is given. That might be acceptable, @benjaminhuth?

@benjaminhuth
Copy link
Member

Interesting that the position where the MT is constructed has such a big impact on the performance...

However, GSF performance is a topic that must be addressed in general at some point, so that is totally fine with the change.

@codecov
Copy link

codecov bot commented Sep 12, 2022

Codecov Report

Merging #1507 (1797f92) into main (087ed98) will decrease coverage by 0.00%.
The diff coverage is 48.10%.

@@            Coverage Diff             @@
##             main    #1507      +/-   ##
==========================================
- Coverage   48.59%   48.58%   -0.01%     
==========================================
  Files         381      381              
  Lines       20631    20649      +18     
  Branches     9463     9475      +12     
==========================================
+ Hits        10026    10033       +7     
+ Misses       4066     4064       -2     
- Partials     6539     6552      +13     
Impacted Files Coverage Δ
Core/include/Acts/TrackFitting/detail/GsfActor.hpp 42.58% <33.33%> (+0.21%) ⬆️
.../include/Acts/TrackFitting/detail/GsfSmoothing.hpp 35.05% <33.33%> (-0.37%) ⬇️
...de/Acts/TrackFinding/CombinatorialKalmanFilter.hpp 32.99% <46.42%> (+0.70%) ⬆️
Core/include/Acts/TrackFitting/KalmanFitter.hpp 45.70% <50.00%> (+0.25%) ⬆️
...re/include/Acts/TrackFitting/GaussianSumFitter.hpp 69.18% <54.54%> (-1.17%) ⬇️
...e/include/Acts/EventData/VectorMultiTrajectory.hpp 52.89% <0.00%> (-2.66%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@paulgessinger
Copy link
Member Author

I think this is working now, can you reapprove @benjaminhuth?

@kodiakhq kodiakhq bot merged commit eb94af6 into acts-project:main Sep 13, 2022
@paulgessinger paulgessinger mentioned this pull request Sep 14, 2022
2 tasks
benjaminhuth pushed a commit to benjaminhuth/acts that referenced this pull request Sep 19, 2022
This PR changes the CKF and KF to reuse the same MultiTrajectory. CKF does this internally, retaining a single MTJ outside the for loop over the seeds. KF's `fit()` method now accepts an optional `trajectory` argument, that it will append track states into. If it's not given, it will create a fresh MTJ.

This cuts down on the number of objects we have flying around.

In the post-processing of CKF outputs via `Trajectory` objects, all of the objects per event will now point to the same MTJ. I plan to refactor this when the Track EDM lands.
@paulgessinger paulgessinger modified the milestones: next, v20.2.0 Sep 23, 2022
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