Skip to content
Open
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
24 changes: 14 additions & 10 deletions src/coreclr/gc/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25492,10 +25492,14 @@ int gc_heap::calculate_new_heap_count ()
{
if (((int)dynamic_heap_count_data.last_changed_count > 0) && (dynamic_heap_count_data.last_changed_gc_index > 0.0))
{
(dynamic_heap_count_data.inc_failure_count)++;
dprintf (6666, ("[CHP0-4] just grew %d GCs ago, grow more aggressively from %d -> %d more heaps",
(current_gc_index - dynamic_heap_count_data.last_changed_gc_index), step_up_int, (step_up_int * (dynamic_heap_count_data.inc_failure_count + 1))));
step_up_int *= dynamic_heap_count_data.inc_failure_count + 1;
size_t gc_count_since_last_growth = (current_gc_index - dynamic_heap_count_data.last_changed_gc_index);
if (gc_count_since_last_growth <= dynamic_heap_count_data.inc_failure_gcs_threshold)
{
dynamic_heap_count_data.inc_failure_count = min(dynamic_heap_count_data.inc_failure_count + 1, dynamic_heap_count_data.inc_failure_limit);
dprintf (6666, ("[CHP0-4] just grew %d GCs ago, grow more aggressively from %d -> %d more heaps",
gc_count_since_last_growth, step_up_int, (step_up_int * (dynamic_heap_count_data.inc_failure_count + 1))));
step_up_int *= dynamic_heap_count_data.inc_failure_count + 1;
}
}
}
}
Expand Down Expand Up @@ -25650,19 +25654,19 @@ int gc_heap::calculate_new_heap_count ()
dynamic_heap_count_data.below_target_accumulation = 0;
}

if (dynamic_heap_count_data.inc_failure_count)
{
dprintf (6666, ("[CHP1] shrink, reset inc failure count (was %d)", dynamic_heap_count_data.inc_failure_count));
dynamic_heap_count_data.inc_failure_count = 0;
}

if (new_n_heaps < n_heaps)
{
dynamic_heap_count_data.last_changed_gc_index = current_gc_index;
dynamic_heap_count_data.last_changed_count = (float)(new_n_heaps - n_heaps);
dynamic_heap_count_data.last_changed_stcp = smoothed_median_throughput_cost_percent;
dprintf (6666, ("[CHP1] setting last changed gc index to %Id, count to %.3f, stcp to %.3f",
dynamic_heap_count_data.last_changed_gc_index, dynamic_heap_count_data.last_changed_count, dynamic_heap_count_data.last_changed_stcp));

if (dynamic_heap_count_data.inc_failure_count)
{
dprintf (6666, ("[CHP1] shrink, reset inc failure count (was %d)", dynamic_heap_count_data.inc_failure_count));
dynamic_heap_count_data.inc_failure_count = 0;
}
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/coreclr/gc/gcpriv.h
Original file line number Diff line number Diff line change
Expand Up @@ -4339,8 +4339,11 @@ class gc_heap
// For tuning above/below target tcp.
//
// If we just increased the heap count and immediately need to grow again, that counts as a failure.
// The higher the failure count, the more aggressive we should grow.
// The higher the failure count, the more aggressive we should grow, but only to a point.
int inc_failure_count;
const int inc_failure_limit = 2;
// After enough GCs without growth, we should stop being aggressive due to the failure count.
const int inc_failure_gcs_threshold = 40;

// If we are trending up and the tcp is already close enough to target, we need this many samples
// before we adjust.
Expand Down