You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
gh-148722: Make code objects support cyclic GC - #151155
Fix code-object reference cycles in GIL-enabled builds by making code objects participate in cyclic garbage collection.
The change uses GC allocation and deallocation for code objects in all builds, enables tp_traverse, and visits co_consts. It also adds a regression test that verifies a cycle from co_consts back to the code object is collected.
Summary of the results of the build (if available):
==
Click to see traceback logs
Traceback (most recent call last):
File "/var/lib/buildbot/worker/cstratak-rhel9-s390x/3.x.cstratak-rhel9-s390x.refleak/build/Lib/contextlib.py", line 116, in innerreturn func(*args, **kwds)
File "/var/lib/buildbot/worker/cstratak-rhel9-s390x/3.x.cstratak-rhel9-s390x.refleak/build/Lib/test/_test_multiprocessing.py", line 651, in test_interrupt
exitcode =self._kill_process(multiprocessing.Process.interrupt)
File "/var/lib/buildbot/worker/cstratak-rhel9-s390x/3.x.cstratak-rhel9-s390x.refleak/build/Lib/contextlib.py", line 116, in innerreturn func(*args, **kwds)
File "/var/lib/buildbot/worker/cstratak-rhel9-s390x/3.x.cstratak-rhel9-s390x.refleak/build/Lib/test/_test_multiprocessing.py", line 632, in _kill_processself.assertEqual(join(), None)
~~~~^^
File "/var/lib/buildbot/worker/cstratak-rhel9-s390x/3.x.cstratak-rhel9-s390x.refleak/build/Lib/test/_test_multiprocessing.py", line 305, in __call__returnself.func(*args, **kwds)
~~~~~~~~~^^^^^^^^^^^^^^^
File "/var/lib/buildbot/worker/cstratak-rhel9-s390x/3.x.cstratak-rhel9-s390x.refleak/build/Lib/multiprocessing/process.py", line 156, in join
res =self._popen.wait(timeout)
File "/var/lib/buildbot/worker/cstratak-rhel9-s390x/3.x.cstratak-rhel9-s390x.refleak/build/Lib/multiprocessing/popen_fork.py", line 44, in waitreturnself.poll(os.WNOHANGif timeout ==0.0else0)
~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/lib/buildbot/worker/cstratak-rhel9-s390x/3.x.cstratak-rhel9-s390x.refleak/build/Lib/multiprocessing/popen_fork.py", line 28, in poll
pid, sts = os.waitpid(self.pid, flag)
~~~~~~~~~~^^^^^^^^^^^^^^^^
File "/var/lib/buildbot/worker/cstratak-rhel9-s390x/3.x.cstratak-rhel9-s390x.refleak/build/Lib/test/_test_multiprocessing.py", line 628, in handlerraiseRuntimeError(f'join took longer than {timeout} seconds: {p}')
RuntimeError: join took longer than 67.5 seconds: <Process name='Process-2' pid=3019283 parent=3019280 started daemon>
Traceback (most recent call last):
File "/var/lib/buildbot/worker/cstratak-rhel9-s390x/3.x.cstratak-rhel9-s390x.refleak/build/Lib/multiprocessing/process.py", line 320, in _bootstrapself.run()
~~~~~~~~^^
File "/var/lib/buildbot/worker/cstratak-rhel9-s390x/3.x.cstratak-rhel9-s390x.refleak/build/Lib/multiprocessing/process.py", line 108, in runself._target(*self._args, **self._kwargs)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/lib/buildbot/worker/cstratak-rhel9-s390x/3.x.cstratak-rhel9-s390x.refleak/build/Lib/test/_test_multiprocessing.py", line 579, in _sleep_some_event
time.sleep(100)
~~~~~~~~~~^^^^^
KeyboardInterrupt
k
Traceback (most recent call last):
File "/var/lib/buildbot/worker/cstratak-rhel9-s390x/3.x.cstratak-rhel9-s390x.refleak/build/Lib/contextlib.py", line 116, in innerreturn func(*args, **kwds)
File "/var/lib/buildbot/worker/cstratak-rhel9-s390x/3.x.cstratak-rhel9-s390x.refleak/build/Lib/test/_test_multiprocessing.py", line 651, in test_interrupt
exitcode =self._kill_process(multiprocessing.Process.interrupt)
File "/var/lib/buildbot/worker/cstratak-rhel9-s390x/3.x.cstratak-rhel9-s390x.refleak/build/Lib/contextlib.py", line 116, in innerreturn func(*args, **kwds)
File "/var/lib/buildbot/worker/cstratak-rhel9-s390x/3.x.cstratak-rhel9-s390x.refleak/build/Lib/test/_test_multiprocessing.py", line 632, in _kill_processself.assertEqual(join(), None)
~~~~^^
File "/var/lib/buildbot/worker/cstratak-rhel9-s390x/3.x.cstratak-rhel9-s390x.refleak/build/Lib/test/_test_multiprocessing.py", line 305, in __call__returnself.func(*args, **kwds)
~~~~~~~~~^^^^^^^^^^^^^^^
File "/var/lib/buildbot/worker/cstratak-rhel9-s390x/3.x.cstratak-rhel9-s390x.refleak/build/Lib/multiprocessing/process.py", line 156, in join
res =self._popen.wait(timeout)
File "/var/lib/buildbot/worker/cstratak-rhel9-s390x/3.x.cstratak-rhel9-s390x.refleak/build/Lib/multiprocessing/popen_fork.py", line 44, in waitreturnself.poll(os.WNOHANGif timeout ==0.0else0)
~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/lib/buildbot/worker/cstratak-rhel9-s390x/3.x.cstratak-rhel9-s390x.refleak/build/Lib/multiprocessing/popen_fork.py", line 28, in poll
pid, sts = os.waitpid(self.pid, flag)
~~~~~~~~~~^^^^^^^^^^^^^^^^
File "/var/lib/buildbot/worker/cstratak-rhel9-s390x/3.x.cstratak-rhel9-s390x.refleak/build/Lib/test/_test_multiprocessing.py", line 628, in handlerraiseRuntimeError(f'join took longer than {timeout} seconds: {p}')
RuntimeError: join took longer than 67.5 seconds: <Process name='Process-1370' pid=2927251 parent=2903984 started daemon>
Summary of the results of the build (if available):
==
Click to see traceback logs
Traceback (most recent call last):
File "/var/lib/buildbot/worker/cstratak-fedora-stable-aarch64/3.x.cstratak-fedora-stable-aarch64.refleak/build/Lib/test/test_os/test_os.py", line 4523, in test_timerfd_ns_TFD_TIMER_ABSTIMEself.assertLess(abs(next_expiration_ns - offset_ns), limit_error)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^AssertionError: 2648893 not less than 1000000
IIUC, we expect gc_traversal and create_gc_cycles to spend more time in the GC now that there are more GC-enabled objects.
It's good that the other benchmarks are unaffected.
@StanFromIreland I think #163168 should mitigate it. VM created code objects won't be tracked but user-created ones that can include cycles will so it generally shouldn't cause GC overhead.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
staleStale PR or inactive for long period of time.
5 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix code-object reference cycles in GIL-enabled builds by making code objects participate in cyclic garbage collection.
The change uses GC allocation and deallocation for code objects in all builds, enables
tp_traverse, and visitsco_consts. It also adds a regression test that verifies a cycle fromco_constsback to the code object is collected.Closes #148722.
Tests:
make -j8./python.exe -m test test_code test_marshal test_gc