-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
New GC decommit strategy for large/huge regions #109431
Conversation
markples
commented
Oct 31, 2024
•
edited
Loading
edited
- Use age rather than budget for determining whether large and huge regions should be decommitted
- Combine new age logic with previous age logic for basic regions
- Simply add aged regions to decommit list. In the future, this can be combined with move_highest_free_regions with age swapping to optimize which regions are decommitted
- Factor modified portions of distribute_free_regions into helper functions
- Simplify distribute_free_regions when logic now only applies to basic regions
- Add logic to more aggressively decommit in high-memory-usage situations
- Call distribute_free_regions during BGC (or during ephemeral "pre-GC" to a BGC if one occurs)
Tagging subscribers to this area: @dotnet/gc |
src/coreclr/gc/gc.cpp
Outdated
@@ -53336,6 +53465,7 @@ bool gc_heap::compute_memory_settings(bool is_initialization, uint32_t& nhp, uin | |||
} | |||
|
|||
m_high_memory_load_th = min ((high_memory_load_th + 5), v_high_memory_load_th); | |||
almost_high_memory_load_th = max((high_memory_load_th - 5), 1u); | |||
|
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.
since this can be set by a config it can be smaller than 5 so this can't be an unsigned number.
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.
good catch, thanks - note also that ~25 lines up there was a possibility for overflow
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.
Mark and I talked about the following couple of changes that he'll do but in general this looks good and we've gone through the perf results -
- make sure we are doing the right check for when we want to decommit (in
distribute_surplus_p
) called at the beginning of a BGC mark phase - add a comment that talks about the policies and operations on the global and local lists (I've written an example for him)
- the calc of
almost_high_memory_load_th
in the comment above - a couple of nit changes for naming
Done but (2)
I believe this is correct. Previously we never called This will go in the comments.
fixed this and a nearby similar problem
done |
Comment added for (2) |
I manually built a new commit with all of these changes as rebase operations to squash some commits together were retriggering old merge conflicts. To see the most recent changes separately, see my backup branch https://github.com/markples/runtime/tree/new-dfr-backup or the specific commits: fix underflow possibility and nearby overflow one or those 5 squashed in https://github.com/markples/runtime/tree/new-dfr-backup-squash at 3eef23b |
// - aged_regions | ||
// - surplus_regions | ||
// | ||
// For reason_induced_aggressive GCs, we decommit all regions. Therefore, the below description is |
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.
// a. A negative balance (deficit) for SOH (basic) will be distributed it means we expect to use | ||
// more memory than we have on the free lists. A negative balance for LOH (large) isn't possible | ||
// for LOH since the budgets start at zero. | ||
// b. For SOH (basic), we will decommit surplus regions unless we are in a foreground GC during BGC. |
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.
this matches old policy. if not decommit then we distribute evenly. "foreground GC" is enough (means during BGC)