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:
Sam Gross 2024-04-29 14:36:02 -04:00 committed by GitHub
parent 8d4b756fd3
commit 7ccacb220d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 134 additions and 8 deletions

View file

@ -13,7 +13,7 @@ import random
import textwrap
from test import support
from test.support import script_helper, ALWAYS_EQ
from test.support import script_helper, ALWAYS_EQ, suppress_immortalization
from test.support import gc_collect
from test.support import import_helper
from test.support import threading_helper
@ -651,6 +651,7 @@ class ReferencesTestCase(TestBase):
# deallocation of c2.
del c2
@suppress_immortalization()
def test_callback_in_cycle(self):
import gc
@ -743,6 +744,7 @@ class ReferencesTestCase(TestBase):
del c1, c2, C, D
gc.collect()
@suppress_immortalization()
def test_callback_in_cycle_resurrection(self):
import gc
@ -878,6 +880,7 @@ class ReferencesTestCase(TestBase):
# No exception should be raised here
gc.collect()
@suppress_immortalization()
def test_classes(self):
# Check that classes are weakrefable.
class A(object):