Skip to content

Conversation

PeterSolMS
Copy link
Contributor

We observed that while distribute_free_regions distributes the number of free regions across heaps reasonably well, sometimes the committed bytes are distributed very unevenly.

This adds a simple algorithm to distribute commit bytes in free regions across heaps. The idea is to exchange regions between heaps with small and large committed bytes in free regions to reduce the difference.

As a second step, we move regions above the minimum commit per heap to a global free list. Added code to get_free_region to allocate from this global free list if the per heap free list is empty. To make this thread safe, I'm using a simple spin lock - the first tests indicate no contention at all, so this may be good enough.

…r* of free regions across heaps reasonably well, sometimes the *committed bytes* are distributed very unevenly.

This adds a simple algorithm to distribute commit bytes in free regions across heaps. The idea is to exchange regions between heaps with small and large committed bytes in free regions to reduce the difference.
…n allocator and the access to the global free regions list.

Rearrange the code in gc_heap::get_free_region to reduce the amount of duplicated code.
… to have both a per heap free list and a global one.
@ghost ghost added the area-GC-coreclr label Oct 28, 2022
@ghost ghost assigned PeterSolMS Oct 28, 2022
@ghost
Copy link

ghost commented Oct 28, 2022

Tagging subscribers to this area: @dotnet/gc
See info in area-owners.md if you want to be subscribed.

Issue Details

We observed that while distribute_free_regions distributes the number of free regions across heaps reasonably well, sometimes the committed bytes are distributed very unevenly.

This adds a simple algorithm to distribute commit bytes in free regions across heaps. The idea is to exchange regions between heaps with small and large committed bytes in free regions to reduce the difference.

As a second step, we move regions above the minimum commit per heap to a global free list. Added code to get_free_region to allocate from this global free list if the per heap free list is empty. To make this thread safe, I'm using a simple spin lock - the first tests indicate no contention at all, so this may be good enough.

Author: PeterSolMS
Assignees: -
Labels:

area-GC-coreclr

Milestone: -

…ization of min_committed/max_committed local variables was happening in the wrong place - these need to be re-initialized for each iteration.
- Fix race condition - can't verify global free regions outside of the lock
- Add more instrumentation.
- Sort global free regions at the end of inserting, rather than keeping them sorted while inserting.
- Adjust distribute_free_regions to inspect and account for global free regions.
…l committed size regions to global free list.

Changed nonstandard %Ix and %Id modifiers to %zx and %zd.
@mangod9
Copy link
Member

mangod9 commented Mar 20, 2023

Is this PR still relevant?

@PeterSolMS
Copy link
Contributor Author

This still needs additional instrumentation to verify that it achieves its goals - closing for now.

@PeterSolMS PeterSolMS closed this Mar 26, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Apr 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants