Uh oh!
There was an error while loading. Please reload this page.
gh-142048: Fix lost allocations on thread cleanup - #142233
Conversation
| // Flush the thread's local GC allocation count to the global count | ||
| // before the thread state is cleared, otherwise the count is lost. | ||
| _PyThreadStateImpl *tstate_impl = (_PyThreadStateImpl *)tstate; | ||
| _Py_atomic_add_int(&tstate->interp->gc.young.count, |
There was a problem hiding this comment.
Since this is less common perhaps it's ok to allow the global GC count to go negative here? The compare-and-exchange loop is more accurate though, I can update to use that if preferred.
There was a problem hiding this comment.
Yeah, I think going negative here is fine
Uh oh!
There was an error while loading. Please reload this page.
Thanks @kevmo314 for the PR, and @kumaraditya303 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14. |
…honGH-142233) (cherry picked from commit 49b1fb4) Co-authored-by: Kevin Wang <kevmo314@gmail.com>
Sorry, @kevmo314 and @kumaraditya303, I could not cleanly backport this to |
GH-142504 is a backport of this pull request to the 3.14 branch. |
GH-142506 is a backport of this pull request to the 3.13 branch. |
…up (pythonGH-142233) (cherry picked from commit 49b1fb4) Co-authored-by: Kevin Wang <kevmo314@gmail.com>
…up (pythonGH-142233) (cherry picked from commit 49b1fb4) Co-authored-by: Kevin Wang <kevmo314@gmail.com>
Fixes some lost allocation counts in the local allocation counters when threads are cleaned up.