Skip to content

[PWGEM] fix memory in builder run 2 - #18862

Merged
hscheid merged 1 commit into
AliceO2Group:masterfrom
Steffimro:pcm-builder-mixed-memory
Nov 23, 2026
Merged

hscheid merged 1 commit into
AliceO2Group:masterfrom
Steffimro:pcm-builder-mixed-memory

Conversation

@Steffimro

Copy link
Copy Markdown
Contributor

The second builder run on the mixed-event tables kept one table iterator per leg row of the whole data frame.This PR fills the cache per artificial event instead.

@github-actions github-actions Bot added pwgem photon Photon and neutral meson PAG label labels Nov 23, 2026
@github-actions

Copy link
Copy Markdown

O2 linter results: ❌ 0 errors, ⚠️ 154 warnings, 🔕 97 disabled

@github-actions github-actions Bot changed the title fix memory in builder run 2 [PWGEM] fix memory in builder run 2 Nov 23, 2026
@Steffimro
Steffimro marked this pull request as ready for review November 23, 2026 08:48
}

// run 2: cache one table iterator per leg of this artificial event for the mixed-event photon pair analysis, to avoid repeated lookups in the legs table
template <typename TMixCollision, typename TMixLegs>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could you please use c++ 20 concepts to help reduce compile time and make it more clear if these are stl containers or tables or iterators.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have changed it now

const auto& ap = mLegIt[photons[i][0] - mLegItFirst];
const auto& am = mLegIt[photons[i][1] - mLegItFirst];
const auto& bp = mLegIt[photons[j][0] - mLegItFirst];
const auto& bm = mLegIt[photons[j][1] - mLegItFirst];

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If I understand correctly mLegIt is a vector of iterators (so like a mini table).
Creation of iterators is quite expansive. It might be better to create iterators outside the double loop once and then just move the values to the corresponding iterator inside the loop.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, mLegIt is a vector of iterators. They are not created inside this loop: cacheLegsOf creates them once per artificial event (one per leg of that event) before the loops, and here I only take a const reference to the cached one. Before this PR the same cache was filled for all legs of the data frame at once, which is what took the memory. I kept a small vector instead of moving one iterator with setCursor because the pairing needs two to four legs at the same time and revisits them.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Sorry the comment was a bit confusing, I meant the creation of ap, am, bp and bm within the double loop. I am not sure if this is the case since they are references tho. So maybe it's not a big issue.

@hscheid
hscheid merged commit 9562570 into AliceO2Group:master Nov 23, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

photon Photon and neutral meson PAG label pwgem

Development

Successfully merging this pull request may close these issues.

3 participants