gh-124218: Refactor per-thread reference counting (#124844)

Currently, we only use per-thread reference counting for heap type objects and
the naming reflects that. We will extend it to a few additional types in an
upcoming change to avoid scaling bottlenecks when creating nested functions.

Rename some of the files and functions in preparation for this change.
This commit is contained in:
Sam Gross 2024-10-01 13:05:42 -04:00 committed by GitHub
parent 5aa91c56bf
commit b482538523
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 168 additions and 167 deletions

View file

@ -3932,7 +3932,7 @@ type_new_alloc(type_new_ctx *ctx)
et->ht_token = NULL;
#ifdef Py_GIL_DISABLED
_PyType_AssignId(et);
et->unique_id = _PyObject_AssignUniqueId((PyObject *)et);
#endif
return type;
@ -5026,7 +5026,7 @@ PyType_FromMetaclass(
#ifdef Py_GIL_DISABLED
// Assign a type id to enable thread-local refcounting
_PyType_AssignId(res);
res->unique_id = _PyObject_AssignUniqueId((PyObject *)res);
#endif
/* Ready the type (which includes inheritance).
@ -6080,7 +6080,7 @@ type_dealloc(PyObject *self)
Py_XDECREF(et->ht_module);
PyMem_Free(et->_ht_tpname);
#ifdef Py_GIL_DISABLED
_PyType_ReleaseId(et);
_PyObject_ReleaseUniqueId(et->unique_id);
#endif
et->ht_token = NULL;
Py_TYPE(type)->tp_free((PyObject *)type);