Conversation
Segmentizer::segments() read the two or three cell boundaries a hit crosses via IAxis::getBinEdges(), which for an equidistant axis constructs and returns the complete edge vector on every call. The four call sites (plane/cylinder x and y, disc r and phi) therefore allocated nBins+1 doubles per axis per hit. With a 1150 x 1450 segmentation (20 um pitch) that is ~2600 doubles allocated and discarded per hit. Profiling an ALICE 3 pp <mu>=30 digitisation showed Axis<Equidistant, Bound>::getBinEdges() at 22% of the algorithm, with a further ~10% of allocator traffic under the same call chain. Index the axis with getBinLowerBound() instead, which is O(1) and allocates nothing. getBinEdges()[i] == getBinLowerBound(i + 1), and the bin indices here are zero-based while getBin() is one-based, so the required edge for zero-based bin index ib is getBinLowerBound(ib + 1); ib never exceeds nBins - 1, so the lookup is always in range. Behaviour is unchanged. ActsUnitTestFatrasSegmentizer (27 cases), ActsUnitTestFatrasChannelizer and ActsUnitTestFatrasChannelMerger all pass. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
Public API surface diffNo change to the public API surface. ✅ |
|
Contributor
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



Segmentizer::segments() read the two or three cell boundaries a hit crosses via IAxis::getBinEdges(), which for an equidistant axis constructs and returns the complete edge vector on every call. The four call sites (plane/cylinder x and y, disc r and phi) therefore allocated nBins+1 doubles per axis per hit.
With a 1150 x 1450 segmentation (20 um pitch) that is ~2600 doubles allocated and discarded per hit. Profiling an ALICE 3 pp =30 digitisation showed Axis<Equidistant, Bound>::getBinEdges() at 22% of the algorithm, with a further ~10% of allocator traffic under the same call chain.
Index the axis with getBinLowerBound() instead, which is O(1) and allocates nothing. getBinEdges()[i] == getBinLowerBound(i + 1), and the bin indices here are zero-based while getBin() is one-based, so the required edge for zero-based bin index ib is getBinLowerBound(ib + 1); ib never exceeds nBins - 1, so the lookup is always in range. Behaviour is unchanged.
ActsUnitTestFatrasSegmentizer (27 cases), ActsUnitTestFatrasChannelizer and ActsUnitTestFatrasChannelMerger all pass.