mirror of
https://github.com/python/cpython.git
synced 2025-10-29 01:22:59 +00:00
gh-117783: Immortalize objects that use deferred reference counting (#118112)
Deferred reference counting is not fully implemented yet. As a temporary measure, we immortalize objects that would use deferred reference counting to avoid multi-threaded scaling bottlenecks. This is only performed in the free-threaded build once the first non-main thread is started. Additionally, some tests, including refleak tests, suppress this behavior.
This commit is contained in:
parent
8d4b756fd3
commit
7ccacb220d
13 changed files with 134 additions and 8 deletions
|
|
@ -312,6 +312,18 @@ struct _gc_runtime_state {
|
|||
collections, and are awaiting to undergo a full collection for
|
||||
the first time. */
|
||||
Py_ssize_t long_lived_pending;
|
||||
|
||||
/* gh-117783: Deferred reference counting is not fully implemented yet, so
|
||||
as a temporary measure we treat objects using deferred referenence
|
||||
counting as immortal. */
|
||||
struct {
|
||||
/* Immortalize objects instead of marking them as using deferred
|
||||
reference counting. */
|
||||
int enabled;
|
||||
|
||||
/* Set enabled=1 when the first background thread is created. */
|
||||
int enable_on_thread_created;
|
||||
} immortalize;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
@ -343,6 +355,11 @@ extern void _PyGC_ClearAllFreeLists(PyInterpreterState *interp);
|
|||
extern void _Py_ScheduleGC(PyThreadState *tstate);
|
||||
extern void _Py_RunGC(PyThreadState *tstate);
|
||||
|
||||
#ifdef Py_GIL_DISABLED
|
||||
// gh-117783: Immortalize objects that use deferred reference counting
|
||||
extern void _PyGC_ImmortalizeDeferredObjects(PyInterpreterState *interp);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue