Skip to content

Commit

Permalink
Dynamic heap count (#86245)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
PeterSolMS authored May 23, 2023
1 parent 22088fb commit f6f7d89
Show file tree
Hide file tree
Showing 8 changed files with 2,533 additions and 222 deletions.
2,283 changes: 2,165 additions & 118 deletions src/coreclr/gc/gc.cpp

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/coreclr/gc/gcconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ class GCConfigStringHolder
INT_CONFIG (GCConserveMem, "GCConserveMemory", "System.GC.ConserveMemory", 0, "Specifies how hard GC should try to conserve memory - values 0-9") \
INT_CONFIG (GCWriteBarrier, "GCWriteBarrier", NULL, 0, "Specifies whether GC should use more precise but slower write barrier") \
STRING_CONFIG(GCName, "GCName", "System.GC.Name", "Specifies the path of the standalone GC implementation.") \
INT_CONFIG (GCSpinCountUnit, "GCSpinCountUnit", 0, 0, "Specifies the spin count unit used by the GC.")
INT_CONFIG (GCSpinCountUnit, "GCSpinCountUnit", 0, 0, "Specifies the spin count unit used by the GC.") \
BOOL_CONFIG (GCDynamicAdaptation, "GCDynamicAdaptation", NULL, false, "Enables varying the heap count dynamically in Server GC.")
// This class is responsible for retreiving configuration information
// for how the GC should operate.
class GCConfig
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/gc/gcinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,7 @@ struct ScanContext
{
Thread* thread_under_crawl;
int thread_number;
int thread_count;
uintptr_t stack_limit; // Lowest point on the thread stack that the scanning logic is permitted to read
bool promotion; //TRUE: Promotion, FALSE: Relocation.
bool concurrent; //TRUE: concurrent scanning
Expand All @@ -1085,6 +1086,7 @@ struct ScanContext

thread_under_crawl = 0;
thread_number = -1;
thread_count = -1;
stack_limit = 0;
promotion = false;
concurrent = false;
Expand Down
Loading

0 comments on commit f6f7d89

Please sign in to comment.