gh-153946: Add API to defer automatic garbage collection#154188
gh-153946: Add API to defer automatic garbage collection#154188pablogsal wants to merge 3 commits into
Conversation
|
I ran this a few times on release builds pinned to one CPU, comparing
I also ran I tried scheduling a collection directly from |
| // Close the race with a deferral that started before the world stopped. | ||
| if (state->reason == _Py_GC_REASON_HEAP && | ||
| _Py_atomic_load_int( | ||
| &state->gcstate->automatic_collection_pause_count)) { | ||
| _PyEval_StartTheWorld(interp); | ||
| return false; | ||
| } |
There was a problem hiding this comment.
Do we need a similar check before this?
Lines 1486 to 1497 in fe0cc2b
This is a very shy question, so please treat it with a huge grain of salt. My hunch is that GC callbacks may still cause race, since they're just regular Python code and may release GIL:
Lines 1467 to 1472 in fe0cc2b
I interrogated Claude Opus to show me what is the actual place for invoking and returning from the callbacks, and that's how I arrived at 1486.
No description provided.