Skip to content

Commit d451ace

Browse files
committed
Lower scaling factor
1 parent 9d28e99 commit d451ace

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

Lib/test/test_gc.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,13 +1108,14 @@ def make_ll(depth):
11081108
olds = []
11091109
gc.collect()
11101110
baseline_live = _testinternalcapi.get_heap_size()
1111-
for i in range(20_000):
1111+
iterations = 200_000 if support.is_resource_enabled('cpu') else 20_000
1112+
for i in range(iterations):
11121113
newhead = make_ll(20)
11131114
newhead.surprise = head
11141115
olds.append(newhead)
11151116
if len(olds) == 20:
11161117
live = _testinternalcapi.get_heap_size()
1117-
self.assertLess(live-baseline_live, 25000)
1118+
self.assertLess(live, baseline_live*2)
11181119
del olds[:]
11191120
if not enabled:
11201121
gc.disable()

Python/gc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,8 +1287,8 @@ gc_list_set_space(PyGC_Head *list, int space)
12871287
*/
12881288

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

12931293
static void
12941294
add_stats(GCState *gcstate, int gen, struct gc_collection_stats *stats)
@@ -1461,7 +1461,7 @@ gc_collect_increment(PyThreadState *tstate, struct gc_collection_stats *stats)
14611461
gc_list_validate_space(&survivors, gcstate->visited_space);
14621462
gc_list_merge(&survivors, visited);
14631463
assert(gc_list_is_empty(&increment));
1464-
Py_ssize_t delta = gcstate->heap_size - gcstate->prior_heap_size;
1464+
Py_ssize_t delta = (gcstate->heap_size - gcstate->prior_heap_size)*2;
14651465
delta += gcstate->young.threshold * SCAN_RATE_MULTIPLIER / scale_factor;
14661466
if (delta > 0) {
14671467
gcstate->work_to_do += delta;

0 commit comments

Comments
 (0)