Skip to content

Commit f6f7d89

Browse files
authored
Dynamic heap count (#86245)
This is an initial implementation for changing the GC heap count dynamically in response to changing load conditions. Using more heaps will increase memory footprint, but in most cases also improve throughput because more GC work is parallelized, and lock contention on the allocation code path is reduced by spreading the load. We try to keep the measured overhead from lock contention and GC pauses at 5% or below, and only reduce the heap count if the measured overhead is below 1% and we estimate a significant reduction in memory footprint. There is some more fine tuning for the cases where smaller reductions in either footprint or overhead are possible without impacting the other side of the equation too much. Because the input data for GC pause etc. are quite noisy, we use a median of 3 filter before the data is used to make decisions. Preliminary data suggests this is effective, but we may need to do more filtering if gains in either direction appear to be small.
1 parent 22088fb commit f6f7d89

File tree

8 files changed

+2533
-222
lines changed

8 files changed

+2533
-222
lines changed

src/coreclr/gc/gc.cpp

Lines changed: 2165 additions & 118 deletions
Large diffs are not rendered by default.

src/coreclr/gc/gcconfig.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ class GCConfigStringHolder
137137
INT_CONFIG (GCConserveMem, "GCConserveMemory", "System.GC.ConserveMemory", 0, "Specifies how hard GC should try to conserve memory - values 0-9") \
138138
INT_CONFIG (GCWriteBarrier, "GCWriteBarrier", NULL, 0, "Specifies whether GC should use more precise but slower write barrier") \
139139
STRING_CONFIG(GCName, "GCName", "System.GC.Name", "Specifies the path of the standalone GC implementation.") \
140-
INT_CONFIG (GCSpinCountUnit, "GCSpinCountUnit", 0, 0, "Specifies the spin count unit used by the GC.")
140+
INT_CONFIG (GCSpinCountUnit, "GCSpinCountUnit", 0, 0, "Specifies the spin count unit used by the GC.") \
141+
BOOL_CONFIG (GCDynamicAdaptation, "GCDynamicAdaptation", NULL, false, "Enables varying the heap count dynamically in Server GC.")
141142
// This class is responsible for retreiving configuration information
142143
// for how the GC should operate.
143144
class GCConfig

src/coreclr/gc/gcinterface.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,6 +1068,7 @@ struct ScanContext
10681068
{
10691069
Thread* thread_under_crawl;
10701070
int thread_number;
1071+
int thread_count;
10711072
uintptr_t stack_limit; // Lowest point on the thread stack that the scanning logic is permitted to read
10721073
bool promotion; //TRUE: Promotion, FALSE: Relocation.
10731074
bool concurrent; //TRUE: concurrent scanning
@@ -1085,6 +1086,7 @@ struct ScanContext
10851086

10861087
thread_under_crawl = 0;
10871088
thread_number = -1;
1089+
thread_count = -1;
10881090
stack_limit = 0;
10891091
promotion = false;
10901092
concurrent = false;

0 commit comments

Comments
 (0)