Skip to content
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

Adjust regions range dynamically based on memory limits #71164

Merged
merged 2 commits into from
Jun 30, 2022

Conversation

cshung
Copy link
Member

@cshung cshung commented Jun 22, 2022

This change fixes the working set regression when running the JSON TechEmpower benchmark on Linux under a container. Here is a summary of the performance data:

Segments:
Max Working Set (MB) | 93

Regions before fix:
Max Working Set (MB) | 172

Regions after fix:
Max Working Set (MB) | 95

There is no significant difference between regions after fix and segment on other metrics we measured.

Cause of the regression:
In the GC, we assumed that GCToOSInterface::VirtualReserve is essentially free because all it does is that it tells the operating system what virtual address range is not available for other uses within the process. This assumption holds on Windows, but on Linux, the APIs are emulated, and for each page we reserve, we use 1 byte to describe that page so that it can satisfy other needs (e.g. VirtualQuery)

On a 64-bit system, the address space is huge, and therefore the GC reserved 256G by default. That translate to 64M of memory used just to track those pages. But we are running under a container of 512MB, we will never ever need those pages.

Solution:
The proper root cause fix is to avoid those tracking bytes, that work is tracked as part of #31721 and is currently out of the scope of .NET 7. In the meantime, there is no need to reserve 256G of memory on a container of 512MB. In this change, I made that reserve limit dynamic, depending on the machine. This will also fix issue #70718 because if you have a large physical memory, our reserve limit would be adjusted accordingly.

@ghost
Copy link

ghost commented Jun 22, 2022

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

Issue Details

null

Author: cshung
Assignees: cshung
Labels:

area-GC-coreclr

Milestone: -

@cshung cshung changed the title Adjust regions range dynamically based on memory limits [WIP] Adjust regions range dynamically based on memory limits Jun 22, 2022
src/coreclr/gc/gc.cpp Outdated Show resolved Hide resolved
@cshung cshung force-pushed the public/adjust-regions-range branch from 34cbc57 to a976d70 Compare June 24, 2022 19:37
@cshung cshung changed the title [WIP] Adjust regions range dynamically based on memory limits Adjust regions range dynamically based on memory limits Jun 27, 2022
src/coreclr/gc/gc.cpp Outdated Show resolved Hide resolved
@cshung cshung merged commit bb36771 into dotnet:main Jun 30, 2022
@cshung cshung deleted the public/adjust-regions-range branch June 30, 2022 20:12
@ghost ghost locked as resolved and limited conversation to collaborators Jul 31, 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.

3 participants