Skip to content

Simplify memory regulation logic#16837

Merged
vepadulano merged 3 commits intoroot-project:masterfrom
vepadulano:pyroot-tmemoryregulator-destruction-order
Nov 8, 2024
Merged

Simplify memory regulation logic#16837
vepadulano merged 3 commits intoroot-project:masterfrom
vepadulano:pyroot-tmemoryregulator-destruction-order

Conversation

@vepadulano
Copy link
Copy Markdown
Member

With all these changes, I do not see anymore failures in a local run with the ubuntu 24.10 CI image. let's see if the rest of the CI agrees. Note that one of the changes is equivalent to #16671

@vepadulano vepadulano requested a review from guitargeek November 6, 2024 14:10
@vepadulano vepadulano self-assigned this Nov 6, 2024
@vepadulano vepadulano requested a review from dpiparo as a code owner November 6, 2024 14:10
@vepadulano vepadulano changed the title Pyroot tmemoryregulator destruction order Simplify memory regulation logci Nov 6, 2024
@vepadulano vepadulano changed the title Simplify memory regulation logci Simplify memory regulation logic Nov 6, 2024
@vepadulano vepadulano force-pushed the pyroot-tmemoryregulator-destruction-order branch from adf6a99 to b8589d7 Compare November 6, 2024 14:16
@github-actions
Copy link
Copy Markdown

github-actions bot commented Nov 6, 2024

Test Results

    19 files      19 suites   4d 9h 35m 18s ⏱️
 2 664 tests  2 664 ✅ 0 💤 0 ❌
48 706 runs  48 706 ✅ 0 💤 0 ❌

Results for commit 4baf51d.

♻️ This comment has been updated with latest results.

Copy link
Copy Markdown
Contributor

@guitargeek guitargeek left a comment

Choose a reason for hiding this comment

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

This is really great, and the CI also starts to be green! The failures are unrelated and caused by #16697. FYI, @ferdymercury.

@ferdymercury
Copy link
Copy Markdown
Collaborator

The failures are unrelated and caused by #16697. FYI, @ferdymercury.

Yep, it's because the sibling roottest PR was overlooked. (Should have been merged simultaneously)

* Remove usage of lambda with capture of class data member, move to free
  functions with singleton.
* Remove TMemoryRegulator class and only keep the needed functionality in RegulatorCleanup
* Remove extra call to `ClearProxiedObjects`, as those objects are automatically deregistered by the
  Python GC through cppyy's memory regulator.

The only remaining feature for the PyROOT atexit cleanup logic is the
`CallCppyyRecursiveRemove` function that is still required for TObject-derived instances.
Unfortunately, it is still somewhat fragile. With the changes in this commit,
which bring back our full suite of CI platforms to green, the interplay between
`CPyCppyy::MemoryRegulator::RecursiveRemove` and our own map of tracked objects
is subtle. At the moment it looks like the call to `RecursiveRemove` may
invalidate the memory pointed to by the map bucket, so we erase that first.
This avoids potential double-delete situations that might arise during the
atexit cleanup logic of PyROOT.
@vepadulano vepadulano force-pushed the pyroot-tmemoryregulator-destruction-order branch from 3f53362 to 4baf51d Compare November 8, 2024 09:17
@vepadulano
Copy link
Copy Markdown
Member Author

I have added more comments to the commit descriptions. Once the CI confirms these changes indeed work I will merge. Also, we can merge the CI for ubuntu24.10 directly with this PR.

@guitargeek
Copy link
Copy Markdown
Contributor

Nice! And cool to see that it also works on Fedora 41 with Python 3.13

@vepadulano vepadulano merged commit 5076594 into root-project:master Nov 8, 2024
@guitargeek guitargeek mentioned this pull request Nov 13, 2024
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants