]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-110481: Implement inter-thread queue for biased reference counting (#114824)
authorSam Gross <colesbury@gmail.com>
Fri, 9 Feb 2024 22:08:32 +0000 (17:08 -0500)
committerGitHub <noreply@github.com>
Fri, 9 Feb 2024 22:08:32 +0000 (17:08 -0500)
commita3af3cb4f424034b56404704fdf8f18e8c0a9982
tree62ee00ea8725669a67c0fb9f7d8692fedf55bbae
parenta225520af941fb125a4ede77a617501dfb8b46da
gh-110481: Implement inter-thread queue for biased reference counting (#114824)

Biased reference counting maintains two refcount fields in each object:
`ob_ref_local` and `ob_ref_shared`. The true refcount is the sum of these two
fields. In some cases, when refcounting operations are split across threads,
the ob_ref_shared field can be negative (although the total refcount must be
at least zero). In this case, the thread that decremented the refcount
requests that the owning thread give up ownership and merge the refcount
fields.
21 files changed:
Include/internal/pycore_brc.h [new file with mode: 0644]
Include/internal/pycore_ceval.h
Include/internal/pycore_interp.h
Include/internal/pycore_object_stack.h
Include/internal/pycore_tstate.h
Lib/test/test_code.py
Lib/test/test_concurrent_futures/executor.py
Lib/test/test_concurrent_futures/test_process_pool.py
Makefile.pre.in
Modules/posixmodule.c
Objects/dictobject.c
Objects/object.c
PCbuild/_freeze_module.vcxproj
PCbuild/_freeze_module.vcxproj.filters
PCbuild/pythoncore.vcxproj
PCbuild/pythoncore.vcxproj.filters
Python/brc.c [new file with mode: 0644]
Python/ceval_gil.c
Python/gc_free_threading.c
Python/object_stack.c
Python/pystate.c