diff options
author | Sam Gross <colesbury@gmail.com> | 2024-08-06 18:36:57 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-06 18:36:57 (GMT) |
commit | dc093010672207176857a747c61da9c046ad9d3e (patch) | |
tree | 3eeff2ad72faa7781255016cc0f54c45aecd41d7 /Include/cpython | |
parent | 1429651a06611a9dbcb1928b746faf52934c12e2 (diff) | |
download | cpython-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.h | 3 |
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; |