mirror of
https://github.com/python/cpython.git
synced 2025-08-24 18:55:00 +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
|
@ -141,7 +141,8 @@ except ImportError:
|
|||
ctypes = None
|
||||
from test.support import (cpython_only,
|
||||
check_impl_detail, requires_debug_ranges,
|
||||
gc_collect, Py_GIL_DISABLED)
|
||||
gc_collect, Py_GIL_DISABLED,
|
||||
suppress_immortalization)
|
||||
from test.support.script_helper import assert_python_ok
|
||||
from test.support import threading_helper, import_helper
|
||||
from test.support.bytecode_helper import instructions_with_positions
|
||||
|
@ -577,6 +578,7 @@ class CodeConstsTest(unittest.TestCase):
|
|||
|
||||
class CodeWeakRefTest(unittest.TestCase):
|
||||
|
||||
@suppress_immortalization()
|
||||
def test_basic(self):
|
||||
# Create a code object in a clean environment so that we know we have
|
||||
# the only reference to it left.
|
||||
|
@ -827,6 +829,7 @@ if check_impl_detail(cpython=True) and ctypes is not None:
|
|||
self.assertEqual(GetExtra(f.__code__, FREE_INDEX+100,
|
||||
ctypes.c_voidp(100)), 0)
|
||||
|
||||
@suppress_immortalization()
|
||||
def test_free_called(self):
|
||||
# Verify that the provided free function gets invoked
|
||||
# when the code object is cleaned up.
|
||||
|
@ -854,6 +857,7 @@ if check_impl_detail(cpython=True) and ctypes is not None:
|
|||
del f
|
||||
|
||||
@threading_helper.requires_working_threading()
|
||||
@suppress_immortalization()
|
||||
def test_free_different_thread(self):
|
||||
# Freeing a code object on a different thread then
|
||||
# where the co_extra was set should be safe.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue