8000 GH-124567: Reduce overhead of cycle GC. by markshannon · Pull Request #124717 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-124567: Reduce overhead of cycle GC. #124717

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

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Lower scaling factor
  • Loading branch information
markshannon committed Sep 27, 2024
commit d451ace86265f50f115d9327ef9bbdac857eaf38
5 changes: 3 additions & 2 deletions Lib/test/test_gc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1108,13 +1108,14 @@ def make_ll(depth):
olds = []
gc.collect()
baseline_live = _testinternalcapi.get_heap_size()
for i in range(20_000):
iterations = 200_000 if support.is_resource_enabled('cpu') else 20_000
for i in range(iterations):
newhead = make_ll(20)
newhead.surprise = head
olds.append(newhead)
if len(olds) == 20:
live = _testinternalcapi.get_heap_size()
self.assertLess(live-baseline_live, 25000)
self.assertLess(live, baseline_live*2)
del olds[:]
if not enabled:
gc.disable()
Expand Down
6 changes: 3 additions & 3 deletions Python/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1287,8 +1287,8 @@ gc_list_set_space(PyGC_Head *list, int space)
*/

/* Multiply by 5, so that the default incremental threshold of 10
* scans objects at half the rate as the young generation */
#define SCAN_RATE_MULTIPLIER 20
* scans objects at the same rate as the young generation */
#define SCAN_RATE_MULTIPLIER 10

static void
add_stats(GCState *gcstate, int gen, struct gc_collection_stats *stats)
Expand Down Expand Up @@ -1461,7 +1461,7 @@ 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));
Py_ssize_t delta = gcstate->heap_size - gcstate->prior_heap_size;
Py_ssize_t delta = (gcstate->heap_size - gcstate->prior_heap_size)*2;
delta += gcstate->young.threshold * SCAN_RATE_MULTIPLIER / scale_factor;
if (delta > 0) {
gcstate->work_to_do += delta;
Expand Down
0