summaryrefslogtreecommitdiffstats
path: root/Include/cpython
diff options
context:
space:
mode:
authorSam Gross <colesbury@gmail.com>2024-08-06 18:36:57 (GMT)
committerGitHub <noreply@github.com>2024-08-06 18:36:57 (GMT)
commitdc093010672207176857a747c61da9c046ad9d3e (patch)
tree3eeff2ad72faa7781255016cc0f54c45aecd41d7 /Include/cpython
parent1429651a06611a9dbcb1928b746faf52934c12e2 (diff)
downloadcpython-dc093010672207176857a747c61da9c046ad9d3e.zip
cpython-dc093010672207176857a747c61da9c046ad9d3e.tar.gz
cpython-dc093010672207176857a747c61da9c046ad9d3e.tar.bz2
gh-122417: Implement per-thread heap type refcounts (#122418)
The free-threaded build partially stores heap type reference counts in distributed manner in per-thread arrays. This avoids reference count contention when creating or destroying instances. Co-authored-by: Ken Jin <kenjin@python.org>
Diffstat (limited to 'Include/cpython')
-rw-r--r--Include/cpython/object.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/Include/cpython/object.h b/Include/cpython/object.h
index 90cd7b5..e1024dd 100644
--- a/Include/cpython/object.h
+++ b/Include/cpython/object.h
@@ -270,6 +270,9 @@ typedef struct _heaptypeobject {
PyObject *ht_module;
char *_ht_tpname; // Storage for "tp_name"; see PyType_FromModuleAndSpec
struct _specialization_cache _spec_cache; // For use by the specializer.
+#ifdef Py_GIL_DISABLED
+ Py_ssize_t unique_id; // ID used for thread-local refcounting
+#endif
/* here are optional user slots, followed by the members. */
} PyHeapTypeObject;