Uh oh!
There was an error while loading. Please reload this page.
gh-109593: ResourceTracker.ensure_running() calls finalizers - #109620
gh-109593: ResourceTracker.ensure_running() calls finalizers#109620vstinner wants to merge 1 commit into
Conversation
pitrou
commented
Sep 20, 2023
Hmm, but |
vstinner
commented
Sep 20, 2023
Oh, |
vstinner
commented
Sep 20, 2023
What is a process end? |
pitrou
commented
Sep 20, 2023
Sorry, I meant interpreter shutdown. |
339467e to
c1dad09Comparevstinner
commented
Sep 20, 2023
Oh in fact, what I want is to trigger a GC collection: I fixed my PR for that. I confirm that my change fix #109593 (comment) reproducer. @pitrou: Would you mind to review this updated fix? |
multiprocessing: Reduce the risk of reentrant calls to ResourceTracker.ensure_running() by running explicitly a garbage collection, to call pending finalizers, before acquiring the ResourceTracker lock.
c1dad09 to
d11bc95Comparepitrou
commented
Sep 20, 2023
Ok, this is better, but the problem is that Instantiating a semaphore is currently 500x faster than a GC collection, and that's an optimistic measurement without a lot of objects allocated: >>>%timeitgc.collect()
10.7ms ± 352µsperloop (mean ± std. dev. of7runs, 100loopseach)
>>>%timeitmp.Semaphore()
21.7µs ± 395nsperloop (mean ± std. dev. of7runs, 10,000loopseach) |
vstinner
commented
Sep 20, 2023
Do you want to propose a different fix? My concern is that currently, multiprocessing can hang randomly. IMO it's bad and must be fixed. I prefer a slow multiprocessing than a multiprocessing which hangs randomly. Also, I have limited interest in developing the most efficient fix. So if you have free cycles, please go ahead :-) These days, I'm busy fixing tons of buildbot failures:
Obviously, I would be fine with a fast and correct fix for this issue :-) |
pitrou
commented
Sep 20, 2023
Well, TBH, I'm not sure this issue is very common as I don't think I have every seen it elsewhere. But, yes, I'll try to come up with a fix. |
vstinner
commented
Sep 20, 2023
It makes fail more and more buildbots, so for me, it's an urgency. What I mean in my previous message is that I'm considering to fix the issue right now, and we can have time later to revisit the issue and find a better fix (with lower impact on performance). |
pitrou
commented
Sep 20, 2023
This code isn't new, so it's surprising it's failing "more and more"? |
vstinner
commented
Sep 20, 2023
I modified the CI recently to stop ignoring silently tests failing randomly (FAILURE then SUCCESS): pass new The affected buildbot "PPC64LE Fedora Stable Refleaks 3.x" is blocking Python releases, it's part of STABLE buildbots. |
pitrou
commented
Sep 20, 2023
Well... do you want to undo the change on the failing buildbot until we fix this issue? |
Please take a look at alternate PR #109629 |
vstinner
commented
Sep 21, 2023
Oh sure, if i don't have the bandwith to fix regressions, i will undo this change, once we listed failing tests. That would be reasonable. |
vstinner
commented
Sep 21, 2023
Since @pitrou has a better approach, i convert this change to a draft for now. |
multiprocessing: Reduce the risk of reentrant calls to ResourceTracker.ensure_running() by running explicitly all finalizers before acquiring the ResourceTracker lock.