Skip to content

Commit f6734fc

Browse files
author
Maoni0
committed
trigger an initial gen2 if needed
1 parent 0434499 commit f6734fc

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

src/coreclr/gc/gc.cpp

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2863,6 +2863,7 @@ uint64_t gc_heap::last_suspended_end_time = 0;
28632863
uint64_t gc_heap::change_heap_count_time = 0;
28642864
size_t gc_heap::gc_index_full_gc_end = 0;
28652865
uint64_t gc_heap::before_distribute_free_regions_time = 0;
2866+
bool gc_heap::trigger_initial_gen2_p = false;
28662867

28672868
#ifdef BACKGROUND_GC
28682869
bool gc_heap::trigger_bgc_for_rethreading_p = false;
@@ -21058,6 +21059,26 @@ int gc_heap::joined_generation_to_condemn (BOOL should_evaluate_elevation,
2105821059
}
2105921060
#endif //BACKGROUND_GC
2106021061

21062+
#ifdef DYNAMIC_HEAP_COUNT
21063+
if (trigger_initial_gen2_p)
21064+
{
21065+
#ifdef BACKGROUND_GC
21066+
assert (!trigger_bgc_for_rethreading_p);
21067+
assert (!background_running_p());
21068+
#endif //BACKGROUND_GC
21069+
21070+
if (n != max_generation)
21071+
{
21072+
n = max_generation;
21073+
*blocking_collection_p = FALSE;
21074+
21075+
dprintf (6666, ("doing the 1st gen2 GC requested by DATAS"));
21076+
}
21077+
21078+
trigger_initial_gen2_p = false;
21079+
}
21080+
#endif //DYNAMIC_HEAP_COUNT
21081+
2106121082
return n;
2106221083
}
2106321084

@@ -25612,6 +25633,21 @@ void gc_heap::calculate_new_heap_count ()
2561225633

2561325634
if (change_int > 0)
2561425635
{
25636+
// If we do want to grow but the max HC allowed by DATAS is 0, and we haven't done any gen2 GCs yet, we do want to
25637+
// trigger a gen2 right away.
25638+
if (!max_heap_count_growth_datas && !(dynamic_heap_count_data.current_gen2_samples_count))
25639+
{
25640+
trigger_initial_gen2_p = true;
25641+
25642+
dprintf (6666, ("we want to grow but DATAS is limiting, trigger a gen2 right away"));
25643+
#ifdef BACKGROUND_GC
25644+
if (background_running_p())
25645+
{
25646+
trigger_initial_gen2_p = false;
25647+
}
25648+
#endif //BACKGROUND_GC
25649+
}
25650+
2561525651
agg_factor = dynamic_heap_count_data.get_aggressiveness (change_int);
2561625652
if (agg_factor > 1)
2561725653
{
@@ -26217,7 +26253,16 @@ bool gc_heap::change_heap_count (int new_n_heaps)
2621726253
// rethread the free lists
2621826254
for (int gen_idx = 0; gen_idx < total_generation_count; gen_idx++)
2621926255
{
26220-
if (gen_idx != max_generation)
26256+
bool do_rethreading = true;
26257+
26258+
#ifdef BACKGROUND_GC
26259+
if (trigger_bgc_for_rethreading_p && (gen_idx == max_generation))
26260+
{
26261+
do_rethreading = false;
26262+
}
26263+
#endif //BACKGROUND_GC
26264+
26265+
if (do_rethreading)
2622126266
{
2622226267
if (heap_number < old_n_heaps)
2622326268
{

src/coreclr/gc/gcpriv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5127,6 +5127,7 @@ class gc_heap
51275127
// when the BGC ended.
51285128
PER_HEAP_ISOLATED_FIELD_MAINTAINED size_t gc_index_full_gc_end;
51295129

5130+
PER_HEAP_ISOLATED_FIELD_MAINTAINED bool trigger_initial_gen2_p;
51305131
#ifdef BACKGROUND_GC
51315132
// This is set when change_heap_count wants the next GC to be a BGC for rethreading gen2 FL
51325133
// and reset during that BGC.

0 commit comments

Comments
 (0)