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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions src/coreclr/gc/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43855,11 +43855,6 @@ HRESULT GCHeap::Initialize()
{
gc_heap::total_physical_mem = GCToOSInterface::GetPhysicalMemoryLimit (&gc_heap::is_restricted_physical_mem);
}

#ifdef USE_REGIONS
gc_heap::regions_range = (size_t)GCConfig::GetGCRegionRange();
#endif //USE_REGIONS

#ifdef HOST_64BIT
gc_heap::heap_hard_limit = (size_t)GCConfig::GetGCHeapHardLimit();
gc_heap::heap_hard_limit_oh[soh] = (size_t)GCConfig::GetGCHeapHardLimitSOH();
Expand Down Expand Up @@ -43948,6 +43943,23 @@ HRESULT GCHeap::Initialize()
return CLR_E_GC_LARGE_PAGE_MISSING_HARD_LIMIT;
}

#ifdef USE_REGIONS
gc_heap::regions_range = (size_t)GCConfig::GetGCRegionRange();
if (gc_heap::regions_range == 0)
cshung marked this conversation as resolved.
Show resolved Hide resolved
{
if (gc_heap::heap_hard_limit)
{
gc_heap::regions_range = 2 * gc_heap::heap_hard_limit;
}
else
{
gc_heap::regions_range = max(((size_t)256 * 1024 * 1024 * 1024), (size_t)(2 * gc_heap::total_physical_mem));
}
gc_heap::regions_range = align_on_page(gc_heap::regions_range);
cshung marked this conversation as resolved.
Show resolved Hide resolved
}
// TODO: Set config after config API is merged.
#endif //USE_REGIONS

#endif //HOST_64BIT

uint32_t nhp = 1;
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/gc/gcconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class GCConfigStringHolder
INT_CONFIG (GCHeapHardLimit, "GCHeapHardLimit", "System.GC.HeapHardLimit", 0, "Specifies a hard limit for the GC heap") \
INT_CONFIG (GCHeapHardLimitPercent, "GCHeapHardLimitPercent", "System.GC.HeapHardLimitPercent", 0, "Specifies the GC heap usage as a percentage of the total memory") \
INT_CONFIG (GCTotalPhysicalMemory, "GCTotalPhysicalMemory", NULL, 0, "Specifies what the GC should consider to be total physical memory") \
INT_CONFIG (GCRegionRange, "GCRegionRange", NULL, 274877906944L, "Specifies the range for the GC heap") \
INT_CONFIG (GCRegionRange, "GCRegionRange", NULL, 0, "Specifies the range for the GC heap") \
INT_CONFIG (GCRegionSize, "GCRegionSize", NULL, 4194304, "Specifies the size for a basic GC region") \
STRING_CONFIG(LogFile, "GCLogFile", NULL, "Specifies the name of the GC log file") \
STRING_CONFIG(ConfigLogFile, "GCConfigLogFile", NULL, "Specifies the name of the GC config log file") \
Expand Down