Skip to content

[PWGCF] Avoid redundant copying in a loop - #19013

Open
aalkin wants to merge 1 commit into
AliceO2Group:masterfrom
aalkin:fix-loop-copies
Open

aalkin wants to merge 1 commit into
AliceO2Group:masterfrom
aalkin:fix-loop-copies

Conversation

@aalkin

@aalkin aalkin commented Dec 1, 2026

Copy link
Copy Markdown
Member

Using postfix increment and calling .end() on each iteration creates two unnecessary copies of a very heavy iterator object, each having an array of vectors that have to be allocated and deallocated constantly. Luckily, the compiler had managed to optimize this on its own, but any change in combinations internal code breaks the inlining and thus makes each iteration about 12 times slower.

Switching to prefix increment and caching the end iterator avoid this issue entirely, even in a debug build.
Original loop: ~58.2 sec per call
Fixed loop: ~4.7 sec per call

@github-actions github-actions Bot added the pwgcf label Dec 1, 2026
@github-actions github-actions Bot changed the title Avoid redundant copying in a loop [PWGCF] Avoid redundant copying in a loop Dec 1, 2026
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown

O2 linter results: ❌ 0 errors, ⚠️ 3 warnings, 🔕 5 disabled

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

1 participant