-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GH-124567: Reduce overhead of cycle GC. #124717
Conversation
As a quick preliminary check, I would suggest running doc tests, since they indicated the issue at first and caused further findings (see #118891 for details). Currently, it appears to me that the PR achieves the opposite of its purpose. Doctest on main branch takes ~12-15 minutes |
The test at https://github.com/Privat33r-dev/cpython/actions/runs/11082906901/job/30796516669?pr=4 was killed by the 60 minute timeout, less than half-way through the build (source files not fully read). This PR isn't running documentation tests as no files in A |
That's how I triggered it in my repo. I suggest to add/remove space in Docs in this PR as well, so we can see the end result of the changes. I probably should've added further context for clarity. I used this PR as a base to make a PR in my repository, with 1 more commit from me (space change in docs), so Doctest will start automatically. It took more than 1 hour and stopped halfway through, because the job had 1 hour limit set. At the same time, I made a control Doctest in my repo on main branch + minor doc change. It took 13 m: |
@@ -1467,7 +1487,12 @@ gc_collect_increment(PyThreadState *tstate, struct gc_collection_stats *stats) | |||
gc_list_validate_space(&survivors, gcstate->visited_space); | |||
gc_list_merge(&survivors, visited); | |||
assert(gc_list_is_empty(&increment)); | |||
gcstate->work_to_do += gcstate->heap_size / SCAN_RATE_DIVISOR / scale_factor; | |||
Py_ssize_t delta = (gcstate->heap_size - gcstate->prior_heap_size)*3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Binary operations, where two operands require spaces, may be more standard.
(gcstate->heap_size - gcstate->prior_heap_size) * 3
Closing this, as we don't need an urgent fix (3.13 goes back to generational collection) Longer term, I expect reduced reference counting operations to make faster-cpython/ideas#693 viable. The pre-scan to find live objects is definitely worth further investigation, though. |
This PR makes the following changes to cycle GC, to reduce the overhead observed in #124567:
sys.modules
, so they are not scanned this scan._testinternalcapi.get_heap_size()
function for more precise testing of the GCBefore merging, I need to:
I still need benchmarks and stats for this before merging.