From #111968, we now manage free lists as per-thread resources.
But the overhead of this implementation is that gc should traverse the resources of all threads that belong to the interpreter.
Since the clearing multiple per thread resources can be split by multiple thread tasks, it will be beneficial to reduce GC time.
ref: #113584 (comment)
source code:
|
HEAD_LOCK(&_PyRuntime); |
|
_PyThreadStateImpl *tstate = (_PyThreadStateImpl *)interp->threads.head; |
|
while (tstate != NULL) { |
|
_Py_ClearFreeLists(&tstate->freelist_state, 0); |
|
tstate = (_PyThreadStateImpl *)tstate->base.next; |
|
} |
|
HEAD_UNLOCK(&_PyRuntime); |
cc @colesbury