Skip to content

Conversation

@cshung
Copy link
Contributor

@cshung cshung commented Sep 26, 2022

Sometimes, when we ran out of memory on one heap, it appears that a good portion of the committed bytes are still occupied by the region_free_list of other heaps. As of now, our allocator is incapable of using those.

distribute_free_regions attempts to spread them across all heaps evenly, that was done by counting the number of free regions. Unfortunately, sometimes there are regions that are tiny (with only 1 page committed), and for reason that is not very well understood, sometimes, these tiny regions are clustered in a single heap, leading to a heap running out of free committed memory while the others still have it.

This change decommits those small ones so that this unfortunate scenario is alleviated.

There could be alternative solutions (e.g. stealing from some other heaps during allocation, or maintaining a global region free list that can be shared across heaps). These alternative solutions might give better perf characteristics but they are potentially too complicated for .NET 7 now.

@cshung cshung self-assigned this Sep 26, 2022
@ghost
Copy link

ghost commented Sep 26, 2022

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

Issue Details

Sometimes, when we ran out of memory on one heap, it appears that a good portion of the committed bytes are still occupied by the region_free_list of other heaps. As of now, our allocator is incapable of using those.

This change decommits them so that they could be reused by the desired heap after the compacting GC.

There could be alternative solutions (e.g. stealing from some other heaps during allocation, or maintaining a global region free list that can be shared across heaps). These alternative solutions might give better perf characteristics but they are potentially too complicated for .NET 7 now.

Author: cshung
Assignees: cshung
Labels:

area-GC-coreclr

Milestone: -

@cshung cshung marked this pull request as draft September 26, 2022 23:32
@cshung
Copy link
Contributor Author

cshung commented Sep 27, 2022

We can decommit the other generation regions end as well.

@cshung
Copy link
Contributor Author

cshung commented Sep 27, 2022

Make the changes to reset last_gc_before_oom REGIONS only

@cshung cshung force-pushed the public/decommit-when-oom branch 2 times, most recently from 8e1cf76 to 2796094 Compare September 28, 2022 23:03
@cshung cshung force-pushed the public/decommit-when-oom branch from 2796094 to 42ff061 Compare September 30, 2022 21:06
@cshung cshung changed the title Decommit free regions when close to OutOfMemory Decommit small free regions when close to OutOfMemory Sep 30, 2022
@cshung cshung mentioned this pull request Sep 30, 2022
@cshung cshung closed this Oct 7, 2022
@cshung cshung deleted the public/decommit-when-oom branch October 7, 2022 00:51
@ghost ghost locked as resolved and limited conversation to collaborators Nov 6, 2022
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.

1 participant