Skip to content

Clear per-thread free-list concurrently from GC #114016

Open
@corona10

Description

@corona10

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions