-
Notifications
You must be signed in to change notification settings - Fork 5k
New GC decommit strategy for large/huge regions #109431
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
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)
/backport to release/8.0-staging |
Started backporting to release/8.0-staging: https://github.com/dotnet/runtime/actions/runs/14649677126 |
@mangod9 backporting to "release/8.0-staging" failed, the patch most likely resulted in conflicts: $ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch
Applying: new-dfr in one commit
Using index info to reconstruct a base tree...
M src/coreclr/gc/gc.cpp
M src/coreclr/gc/gcpriv.h
Falling back to patching base and 3-way merge...
Auto-merging src/coreclr/gc/gcpriv.h
CONFLICT (content): Merge conflict in src/coreclr/gc/gcpriv.h
Auto-merging src/coreclr/gc/gc.cpp
CONFLICT (content): Merge conflict in src/coreclr/gc/gc.cpp
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 new-dfr in one commit
Error: The process '/usr/bin/git' failed with exit code 128 Please backport manually! |
/backport to release/9.0-staging |
Started backporting to release/9.0-staging: https://github.com/dotnet/runtime/actions/runs/14740889149 |
@mangod9 backporting to "release/9.0-staging" failed, the patch most likely resulted in conflicts: $ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch
Applying: new-dfr in one commit
Using index info to reconstruct a base tree...
M src/coreclr/gc/gc.cpp
M src/coreclr/gc/gcpriv.h
Falling back to patching base and 3-way merge...
Auto-merging src/coreclr/gc/gcpriv.h
Auto-merging src/coreclr/gc/gc.cpp
CONFLICT (content): Merge conflict in src/coreclr/gc/gc.cpp
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 new-dfr in one commit
Error: The process '/usr/bin/git' failed with exit code 128 Please backport manually! |