Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
adjust region sizes based on individual heap sizes
  • Loading branch information
mangod9 authored and github-actions committed Oct 4, 2022
commit 6eaf767a02e8df36f6b9034b2996641b7f37d405
15 changes: 14 additions & 1 deletion src/coreclr/gc/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44897,7 +44897,7 @@ HRESULT GCHeap::Initialize()
{
// Keep the reservation size for regions similar to that for segments.
// We will initially reserve 6x the configured hard limit
gc_heap::regions_range = 6 * gc_heap::heap_hard_limit;
gc_heap::regions_range = 2 * gc_heap::heap_hard_limit;
}
else
{
Expand Down Expand Up @@ -45052,6 +45052,19 @@ HRESULT GCHeap::Initialize()
#ifdef USE_REGIONS
gc_heap::enable_special_regions_p = (bool)GCConfig::GetGCEnableSpecialRegions();
size_t gc_region_size = (size_t)GCConfig::GetGCRegionSize();

// Adjust GCRegionSize based on how large each heap would be, for smaller heaps we would
// like to keep Region sizes small. We choose between 1 (< 64mb), 2 (<128mb) and 4mb (>128mb)
// by default (unless its configured explictly).
if (gc_region_size == 0){
if (gc_heap::regions_range / nhp >= (128 * 1024 * 1024)){
gc_region_size = 4 * 1024 * 1024;
} else if (gc_heap::regions_range / nhp >= (64 * 1024 * 1024)){
gc_region_size = 2 * 1024 * 1024;
} else
gc_region_size = 1 * 1024 * 1024;
}

if (!power_of_two_p(gc_region_size) || ((gc_region_size * nhp * 19) > gc_heap::regions_range))
{
return E_OUTOFMEMORY;
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 @@ -104,7 +104,7 @@ class GCConfigStringHolder
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, 0, "Specifies the range for the GC heap") \
INT_CONFIG (GCRegionSize, "GCRegionSize", NULL, 4194304, "Specifies the size for a basic GC region") \
INT_CONFIG (GCRegionSize, "GCRegionSize", NULL, 0, "Specifies the size for a basic GC region") \
INT_CONFIG (GCEnableSpecialRegions, "GCEnableSpecialRegions", NULL, 0, "Specifies to enable special handling some regions like SIP") \
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