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: Do not allocate memory if the surface is connected with a detector el… #3069

Merged
merged 15 commits into from
Jul 3, 2024

Conversation

junggjo9
Copy link
Contributor

@junggjo9 junggjo9 commented Apr 1, 2024

If the surface has an associated detector element its internal transform is never accessed consuming memory for no-reason. If the transform is a unique_ptr which is released in such cases, the footprint should be reduced

@github-actions github-actions bot added the Component - Core Affects the Core module label Apr 1, 2024
Copy link

codecov bot commented Apr 1, 2024

Codecov Report

Attention: Patch coverage is 23.52941% with 13 lines in your changes missing coverage. Please review.

Project coverage is 47.64%. Comparing base (5885ee8) to head (3939692).

Files Patch % Lines
Core/src/Surfaces/Surface.cpp 30.76% 2 Missing and 7 partials ⚠️
Core/src/Surfaces/PlaneSurface.cpp 0.00% 0 Missing and 2 partials ⚠️
Core/src/Geometry/CylinderLayer.cpp 0.00% 0 Missing and 1 partial ⚠️
Core/src/Geometry/DiscLayer.cpp 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3069      +/-   ##
==========================================
- Coverage   47.65%   47.64%   -0.01%     
==========================================
  Files         507      507              
  Lines       29205    29211       +6     
  Branches    14010    14012       +2     
==========================================
+ Hits        13917    13919       +2     
- Misses       5264     5265       +1     
- Partials    10024    10027       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@junggjo9 junggjo9 changed the title Refactor: Do not allocate memory if the surface is connected with a detector el… refactor: Do not allocate memory if the surface is connected with a detector el… Apr 1, 2024
@paulgessinger
Copy link
Member

This is what we used to have before. I think @asalzburger at some point measured that having the transform locally improved performance. But I forget the details.

@junggjo9
Copy link
Contributor Author

junggjo9 commented Apr 1, 2024

Hmm, the transform is never used if the detector element is present.... Confused, I am

@paulgessinger
Copy link
Member

The transform is only used for surfaces which don't have a detector element. Otherwise the transform is retrieved from the detector element, and that's where for example the alignment is handled.

@junggjo9
Copy link
Contributor Author

junggjo9 commented Apr 2, 2024

Yep, that what I'm saying too ;)

@paulgessinger
Copy link
Member

So for all other surfaces, boundaries etc, the transform is accessed locally.

@asalzburger
Copy link
Contributor

This is what we used to have before. I think @asalzburger at some point measured that having the transform locally improved performance. But I forget the details.

Hi, yes I remember that there was a visible (but small performance change), however, we can just see with this PR if this is still a measurable effect?

@andiwand
Copy link
Contributor

andiwand commented Apr 9, 2024

I could imagine that this is an additional cache miss because of the additional indirection. After measuring this we would have to weight the CPU increase against the MEM decrease

@junggjo9
Copy link
Contributor Author

Results from the propagation test on 3 threads

patched:

10:03:28    Sequencer      INFO      Processed 100000 events in 1223.381458 s (wall clock)
10:03:28    Sequencer      INFO      Average time per event: 48.693846 ms/event

main:

22:24:31    Sequencer      INFO      Processed 100000 events in 1237.661429 s (wall clock)
22:24:31    Sequencer      INFO      Average time per event: 49.130005 ms/event

Johannes Josef Junggeburth added 2 commits April 25, 2024 15:40
@AJPfleger AJPfleger added this to the next milestone May 3, 2024
@AJPfleger
Copy link
Contributor

@junggjo9 @paulgessinger @asalzburger @andiwand
In the tests, it makes a difference of around 1% (not sure if this is significant). How should we proceed with this?

Core/src/Surfaces/Surface.cpp Outdated Show resolved Hide resolved
Core/src/Geometry/CylinderLayer.cpp Outdated Show resolved Hide resolved
Core/src/Geometry/DiscLayer.cpp Outdated Show resolved Hide resolved
Core/src/Surfaces/Surface.cpp Show resolved Hide resolved
Core/src/Surfaces/Surface.cpp Outdated Show resolved Hide resolved
@andiwand
Copy link
Contributor

no significant change in performance - good from my side

image

image

junggjo9 and others added 3 commits June 2, 2024 16:53
Co-authored-by: Andreas Stefl <[email protected]>
@andiwand
Copy link
Contributor

andiwand commented Jun 3, 2024

There are a couple of CI failure

  • Can you check the formatting @junggjo9 ?
  • I guess the CI Bridge ones are false positives
  • codecov complains - I guess because there are a couple more branches which are not directly tested right now? Should we add some unit tests to capture the new behavior?

Copy link
Contributor

@andiwand andiwand left a comment

Choose a reason for hiding this comment

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

lgtm 👍

Copy link

sonarcloud bot commented Jul 3, 2024

@kodiakhq kodiakhq bot merged commit bd98f56 into acts-project:main Jul 3, 2024
51 checks passed
@github-actions github-actions bot removed the automerge label Jul 3, 2024
@acts-project-service acts-project-service added the Breaks Athena build This PR breaks the Athena build label Jul 3, 2024
@paulgessinger paulgessinger modified the milestones: next, v36.0.0 Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaks Athena build This PR breaks the Athena build Component - Core Affects the Core module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants