-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
GH-126491: Lower heap size limit with faster marking #127519
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
Changes from 1 commit
3038a78
c024484
e8497ae
4c1a6bc
6efb4c0
b1c7ab0
07f228b
51ff78e
df907b5
9ca64f5
bda13f4
d9d63c8
57b8820
a607059
1545508
a1a38c8
68fc90b
8893cf5
ba20c7c
8262bf0
3c2116e
72d0284
0f182e2
d3c21bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -541,13 +541,13 @@ garbage. Also, note that `T == M + I` where `M` is the number of objects marked | |||||
as reachable and `I` is the number of objects visited in increments. | ||||||
Everything in `M` is live, so `I ≥ G0` and in practice `I` is closer to `G0 + G1`. | ||||||
|
||||||
If we choose the amount of work done such that `3*M + I == 8N` then we can do | ||||||
If we choose the amount of work done such that `2*M + I == 6N` then we can do | ||||||
do less work in most cases, but are still guaranteed to keep up. | ||||||
Since `I ≥ G0 + G1` (not strictly true, but close enough) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The increments (I) can include some of the live heap, depending on the how much is keep alive by C extensions. |
||||||
`T == M + I == (8N + 2I)/3` and `(8N + 2I)/3 ≥ 4G`, so we can keep up. | ||||||
`T == M + I == (6N + I)/2` and `(6N + I)/2 ≥ 4G`, so we can keep up. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
The reason that this improves performance is that `M` is usually much larger | ||||||
than `I` Suppose `M == 10I`, then `T < 3N`. | ||||||
than `I` Suppose `M == 10I`, then `T ≅ 3N`. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
Finally, instead of using a fixed multiple of 8, we gradually increase it as the | ||||||
heap grows. This avoids wasting work for small heaps and during startup. | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1566,7 +1566,7 @@ assess_work_to_do(GCState *gcstate) | |
scale_factor = 2; | ||
} | ||
intptr_t new_objects = gcstate->young.count; | ||
intptr_t max_heap_fraction = new_objects*7; | ||
intptr_t max_heap_fraction = new_objects*5; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this called There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not for any good reason. I'll rename it. |
||
intptr_t heap_fraction = gcstate->heap_size / SCAN_RATE_DIVISOR / scale_factor; | ||
if (heap_fraction > max_heap_fraction) { | ||
heap_fraction = max_heap_fraction; | ||
|
@@ -1575,7 +1575,8 @@ assess_work_to_do(GCState *gcstate) | |
return new_objects + heap_fraction; | ||
} | ||
|
||
#define MARKING_PROGRESS_MULTIPLIER 3 | ||
/* See Internal GC docs for explanation */ | ||
#define MARKING_PROGRESS_MULTIPLIER 2 | ||
|
||
static void | ||
gc_collect_increment(PyThreadState *tstate, struct gc_collection_stats *stats) | ||
|
Uh oh!
There was an error while loading. Please reload this page.