Decommit region tails (#66008)
authorPeter Sollich <petersol@microsoft.com>
Mon, 7 Mar 2022 13:02:48 +0000 (14:02 +0100)
committerGitHub <noreply@github.com>
Mon, 7 Mar 2022 13:02:48 +0000 (14:02 +0100)
commit942430c5253fe58c11e32fda265bf816a13cb2b4
tree46dfdf9d9257fa68d440b50824d2211ceebae462
parent0022738e10a22c6ffa121604a86c99d45fc3ea78
Decommit region tails (#66008)

I observed that with gen 1 regions, we often get into the situation that gen 1 is much smaller per heap than a region. So it makes sense to decommit the tail end of the last region in an ephemeral generation guided by the budget for that generation.

To implement this, I reactivated decommit_target for regions and have decommit_step call decommit_ephemeral_segment_pages_step which in the regions case needs to synchronize with the allocator. This is done by taking the more space lock.

Note that with default settings, this decommitting logic will usually only apply to gen 1 because normally gen 0 is larger than a region. It can still happen for gen 0 though if gen 0 has pins and thus already has enough space to satisfy the budget. Then we will decommit the tail end of the last region in gen 0.
src/coreclr/gc/gc.cpp
src/coreclr/gc/gcpriv.h