-
Notifications
You must be signed in to change notification settings - Fork 178
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: Avoid allocations in TrapezoidBounds::inside
#3705
Merged
kodiakhq
merged 5 commits into
acts-project:main
from
andiwand:perf-avoid-allocation-in-trapezoid-inside
Oct 10, 2024
Merged
perf: Avoid allocations in TrapezoidBounds::inside
#3705
kodiakhq
merged 5 commits into
acts-project:main
from
andiwand:perf-avoid-allocation-in-trapezoid-inside
Oct 10, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
asalzburger
approved these changes
Oct 10, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool trick.
I think gcc now swallows that, do you want to un-draft it? |
|
Rosie-Hasan
pushed a commit
to Rosie-Hasan/acts
that referenced
this pull request
Nov 13, 2024
Looking at some flame graphs I spotted some allocations in `TrapezoidBounds::inside` which should not be necessary. It does not look like it had a big impact. Apart from that I decided to replace the generic template argument for `insidePolygon` with a span. --- This pull request includes several changes to the `Acts` library, focusing on improving the handling of vertex data by using `std::span` and enhancing the boundary check logic. The most important changes include the introduction of `std::span` for vertex containers, the addition of necessary includes, and the modification of boundary check methods to use `std::span`. ### Improvements to vertex handling: * [`Core/include/Acts/Surfaces/detail/BoundaryCheckHelper.hpp`](diffhunk://#diff-afebd1f0fa546e69aed4734d1011f475e9ece065b5529419c7031fc64a2e5aa6L75-R77): Changed the `insidePolygon` function to use `std::span<const Vector2>` for vertex containers. * [`Core/include/Acts/Surfaces/detail/VerticesHelper.hpp`](diffhunk://#diff-575a21d724214109cec5c36d8f8fc9884ee879564b9f887b481e4cc08c3b294aL177-R179): Modified the `computeClosestPointOnPolygon` function to use `std::span<const Vector2>` for vertex containers. ### Inclusion of necessary headers: * [`Core/include/Acts/Surfaces/detail/BoundaryCheckHelper.hpp`](diffhunk://#diff-afebd1f0fa546e69aed4734d1011f475e9ece065b5529419c7031fc64a2e5aa6R13-R14): Added the `#include <span>` directive. * [`Core/include/Acts/Surfaces/detail/VerticesHelper.hpp`](diffhunk://#diff-575a21d724214109cec5c36d8f8fc9884ee879564b9f887b481e4cc08c3b294aR16): Added the `#include <span>` directive. * [`Core/src/Surfaces/DiamondBounds.cpp`](diffhunk://#diff-602202d907779fe1a0701875345ed35bb225e2431186cb09e845fb622ce259b4R11): Added the `#include "Acts/Definitions/Algebra.hpp"` directive. ### Boundary check logic enhancements: * [`Core/src/Surfaces/DiamondBounds.cpp`](diffhunk://#diff-602202d907779fe1a0701875345ed35bb225e2431186cb09e845fb622ce259b4L25-R36): Updated the `inside` method to use an array of `Vector2` for vertices and the `insidePolygon` function. * [`Core/src/Surfaces/TrapezoidBounds.cpp`](diffhunk://#diff-0db048c0e724a9a5dc84f75e864ddb1f21dac518388c5a51de11a0d72cfd8ce2L92-R92): Changed the vertices container from `std::vector` to an array of `Vector2` in the `inside` method.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Component - Core
Affects the Core module
Fails Athena tests
This PR causes a failure in the Athena tests
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Looking at some flame graphs I spotted some allocations in
TrapezoidBounds::inside
which should not be necessary. It does not look like it had a big impact.Apart from that I decided to replace the generic template argument for
insidePolygon
with a span.This pull request includes several changes to the
Acts
library, focusing on improving the handling of vertex data by usingstd::span
and enhancing the boundary check logic. The most important changes include the introduction ofstd::span
for vertex containers, the addition of necessary includes, and the modification of boundary check methods to usestd::span
.Improvements to vertex handling:
Core/include/Acts/Surfaces/detail/BoundaryCheckHelper.hpp
: Changed theinsidePolygon
function to usestd::span<const Vector2>
for vertex containers.Core/include/Acts/Surfaces/detail/VerticesHelper.hpp
: Modified thecomputeClosestPointOnPolygon
function to usestd::span<const Vector2>
for vertex containers.Inclusion of necessary headers:
Core/include/Acts/Surfaces/detail/BoundaryCheckHelper.hpp
: Added the#include <span>
directive.Core/include/Acts/Surfaces/detail/VerticesHelper.hpp
: Added the#include <span>
directive.Core/src/Surfaces/DiamondBounds.cpp
: Added the#include "Acts/Definitions/Algebra.hpp"
directive.Boundary check logic enhancements:
Core/src/Surfaces/DiamondBounds.cpp
: Updated theinside
method to use an array ofVector2
for vertices and theinsidePolygon
function.Core/src/Surfaces/TrapezoidBounds.cpp
: Changed the vertices container fromstd::vector
to an array ofVector2
in theinside
method.