Skip to content

Conversation

@hageboeck
Copy link
Member

TH1.Fit might call into Python functions, which would require the GIL to
be held. If TH1.Fit holds it, though, the process deadlocks.
Here, the GIL is released before TH1.Fit, which runs fully in C++
anyway.

A test was added with a 30s timeout. It completes in about 1s, unless the
GIL deadlock is maintained.

Fix #21080.

@guitargeek
Copy link
Contributor

Nice, and compute intense functions like these is exactly when the GIL should be released to enable Python multithreading. Did you check the Pythonization also works for TH1-derived classes?

Copy link
Member

@vepadulano vepadulano left a comment

Choose a reason for hiding this comment

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

Nice thanks!

@hageboeck
Copy link
Member Author

Nice, and compute intense functions like these is exactly when the GIL should be released to enable Python multithreading. Did you check the Pythonization also works for TH1-derived classes?

We checked in the interpreter:

>>> import ROOT
>>> ROOT.TH2.Fit.__release_gil__
True

@github-actions
Copy link

github-actions bot commented Feb 3, 2026

Test Results

    22 files      22 suites   3d 21h 25m 16s ⏱️
 3 779 tests  3 779 ✅ 0 💤 0 ❌
75 161 runs  75 161 ✅ 0 💤 0 ❌

Results for commit 2232fb9.

♻️ This comment has been updated with latest results.

@vepadulano vepadulano closed this Feb 3, 2026
@vepadulano vepadulano reopened this Feb 3, 2026
@vepadulano
Copy link
Member

I've taken a look at the MacOS failures. There seems to be some other kind of interference on that platform for two different types of functions that release the GIL, namely the distributed RDataFrame execution and now TH1.Fit. Needs investigation

Copy link
Member

@vepadulano vepadulano left a comment

Choose a reason for hiding this comment

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

Thank you @siliataider for investigating and fixing the failures on MacOS!

The changes LGTM, maybe consider the ruff format suggestions.

@guitargeek
Copy link
Contributor

Some of the ruff suggestions are probably irrelevant now that 647bf1a was merged.

hageboeck and others added 4 commits February 6, 2026 11:12
TH1.Fit might call into Python functions, which would require the GIL to
be held. If TH1.Fit holds it, though, the process deadlocks.
Here, the GIL is released before TH1.Fit, which runs fully in C++
anyway.

Fix root-project#21080.
This saves startup times and collects TH1 tests in one place.
The timeout of the test is reduced because the deadlock would otherwise
show only after 1500s.
@dpiparo
Copy link
Member

dpiparo commented Feb 7, 2026

Thanks for this fix! maybe something to /backport to 6.38 after merging?

@hageboeck
Copy link
Member Author

/backport to 6.38

@hageboeck hageboeck merged commit d48c865 into root-project:master Feb 9, 2026
50 of 53 checks passed
@hageboeck hageboeck deleted the TH1_GIL_problem branch February 9, 2026 08:35
@hageboeck
Copy link
Member Author

/backport to 6.38

@root-project-bot
Copy link

This PR has been backported to branch 6.38:

@dpiparo
Copy link
Member

dpiparo commented Feb 9, 2026

/backport to 6.38

1 similar comment
@dpiparo
Copy link
Member

dpiparo commented Feb 9, 2026

/backport to 6.38

@root-project-bot
Copy link

This PR has been backported to branch 6.38: #21198

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.

Bad interference for TH1.Fit and EnableImplicitMT

6 participants