@@ -44216,42 +44216,48 @@ void gc_heap::init_static_data()
4421644216{
4421744217 size_t gen0_min_size = get_gen0_min_size();
4421844218
44219- size_t gen0_max_size =
44220- #ifdef MULTIPLE_HEAPS
44221- max ((size_t)6*1024*1024, min ( Align(soh_segment_size/2), (size_t)200*1024*1024));
44222- #else //MULTIPLE_HEAPS
44223- (
44224- #ifdef BACKGROUND_GC
44225- gc_can_use_concurrent ?
44226- 6*1024*1024 :
44227- #endif //BACKGROUND_GC
44228- max ((size_t)6*1024*1024, min ( Align(soh_segment_size/2), (size_t)200*1024*1024))
44229- );
44230- #endif //MULTIPLE_HEAPS
44231-
44232- gen0_max_size = max (gen0_min_size, gen0_max_size);
44233-
44234- if (heap_hard_limit)
44235- {
44236- size_t gen0_max_size_seg = soh_segment_size / 4;
44237- dprintf (GTC_LOG, ("limit gen0 max %zd->%zd", gen0_max_size, gen0_max_size_seg));
44238- gen0_max_size = min (gen0_max_size, gen0_max_size_seg);
44239- }
44219+ size_t gen0_max_size = 0;
4424044220
4424144221 size_t gen0_max_size_config = (size_t)GCConfig::GetGCGen0MaxBudget();
4424244222
4424344223 if (gen0_max_size_config)
4424444224 {
44245- gen0_max_size = min (gen0_max_size, gen0_max_size_config) ;
44225+ gen0_max_size = gen0_max_size_config;
4424644226
4424744227#ifdef FEATURE_EVENT_TRACE
4424844228 gen0_max_budget_from_config = gen0_max_size;
4424944229#endif //FEATURE_EVENT_TRACE
4425044230 }
44231+ else
44232+ {
44233+ gen0_max_size =
44234+ #ifdef MULTIPLE_HEAPS
44235+ max ((size_t)6 * 1024 * 1024, min (Align(soh_segment_size / 2), (size_t)200 * 1024 * 1024));
44236+ #else //MULTIPLE_HEAPS
44237+ (
44238+ #ifdef BACKGROUND_GC
44239+ gc_can_use_concurrent ?
44240+ 6 * 1024 * 1024 :
44241+ #endif //BACKGROUND_GC
44242+ max ((size_t)6 * 1024 * 1024, min (Align(soh_segment_size / 2), (size_t)200 * 1024 * 1024))
44243+ );
44244+ #endif //MULTIPLE_HEAPS
44245+
44246+ gen0_max_size = max (gen0_min_size, gen0_max_size);
44247+
44248+ if (heap_hard_limit)
44249+ {
44250+ size_t gen0_max_size_seg = soh_segment_size / 4;
44251+ dprintf (GTC_LOG, ("limit gen0 max %zd->%zd", gen0_max_size, gen0_max_size_seg));
44252+ gen0_max_size = min (gen0_max_size, gen0_max_size_seg);
44253+ }
44254+ }
4425144255
4425244256 gen0_max_size = Align (gen0_max_size);
4425344257 gen0_min_size = min (gen0_min_size, gen0_max_size);
4425444258
44259+ GCConfig::SetGCGen0MaxBudget (gen0_max_size);
44260+
4425544261 // TODO: gen0_max_size has a 200mb cap; gen1_max_size should also have a cap.
4425644262 size_t gen1_max_size = (size_t)
4425744263#ifdef MULTIPLE_HEAPS
@@ -44284,6 +44290,17 @@ void gc_heap::init_static_data()
4428444290 static_data_table[i][0].max_size = gen0_max_size;
4428544291 static_data_table[i][1].max_size = gen1_max_size;
4428644292 }
44293+
44294+ #ifdef DYNAMIC_HEAP_COUNT
44295+ if (gc_heap::dynamic_adaptation_mode == dynamic_adaptation_to_application_sizes)
44296+ {
44297+ gc_heap::dynamic_heap_count_data.min_gen0_new_allocation = gen0_min_size;
44298+ if (gen0_max_size_config)
44299+ {
44300+ gc_heap::dynamic_heap_count_data.max_gen0_new_allocation = gen0_max_size;
44301+ }
44302+ }
44303+ #endif //DYNAMIC_HEAP_COUNT
4428744304}
4428844305
4428944306bool gc_heap::init_dynamic_data()
@@ -49735,13 +49752,43 @@ HRESULT GCHeap::Initialize()
4973549752 }
4973649753 // This should be adjusted based on the target tcp. See comments in gcpriv.h
4973749754 gc_heap::dynamic_heap_count_data.around_target_threshold = 10.0;
49738- // This should really be set as part of computing static data and should take conserve_mem_setting into consideration.
49739- gc_heap::dynamic_heap_count_data.max_gen0_new_allocation = Align (min (dd_max_size (gc_heap::g_heaps[0]->dynamic_data_of (0)), (size_t)(64 * 1024 * 1024)), get_alignment_constant (TRUE));
49740- gc_heap::dynamic_heap_count_data.min_gen0_new_allocation = Align (dd_min_size (gc_heap::g_heaps[0]->dynamic_data_of (0)), get_alignment_constant (TRUE));
4974149755
49742- dprintf (6666, ("datas max gen0 budget %Id, min %Id",
49743- gc_heap::dynamic_heap_count_data.max_gen0_new_allocation, gc_heap::dynamic_heap_count_data.min_gen0_new_allocation));
49756+ int gen0_growth_soh_ratio_percent = (int)GCConfig::GetGCDGen0GrowthPercent();
49757+ if (gen0_growth_soh_ratio_percent)
49758+ {
49759+ gc_heap::dynamic_heap_count_data.gen0_growth_soh_ratio_percent = (int)GCConfig::GetGCDGen0GrowthPercent() * 0.01f;
49760+ }
49761+ // You can specify what sizes you want to allow DATAS to stay within wrt the SOH stable size.
49762+ // By default DATAS allows 10x this size for gen0 budget when the size is small, and 0.1x when the size is large.
49763+ int gen0_growth_min_permil = (int)GCConfig::GetGCDGen0GrowthMinFactor();
49764+ int gen0_growth_max_permil = (int)GCConfig::GetGCDGen0GrowthMaxFactor();
49765+ if (gen0_growth_min_permil)
49766+ {
49767+ gc_heap::dynamic_heap_count_data.gen0_growth_soh_ratio_min = gen0_growth_min_permil * 0.001f;
49768+ }
49769+ if (gen0_growth_max_permil)
49770+ {
49771+ gc_heap::dynamic_heap_count_data.gen0_growth_soh_ratio_max = gen0_growth_max_permil * 0.001f;
49772+ }
49773+
49774+ if (gc_heap::dynamic_heap_count_data.gen0_growth_soh_ratio_min > gc_heap::dynamic_heap_count_data.gen0_growth_soh_ratio_max)
49775+ {
49776+ log_init_error_to_host ("DATAS min permil for gen0 growth %d is greater than max %d, it needs to be lower",
49777+ gc_heap::dynamic_heap_count_data.gen0_growth_soh_ratio_min, gc_heap::dynamic_heap_count_data.gen0_growth_soh_ratio_max);
49778+ return E_FAIL;
49779+ }
49780+
49781+ GCConfig::SetGCDTargetTCP ((int)gc_heap::dynamic_heap_count_data.target_tcp);
49782+ GCConfig::SetGCDGen0GrowthPercent ((int)(gc_heap::dynamic_heap_count_data.gen0_growth_soh_ratio_percent * 100.0f));
49783+ GCConfig::SetGCDGen0GrowthMinFactor ((int)(gc_heap::dynamic_heap_count_data.gen0_growth_soh_ratio_min * 1000.0f));
49784+ GCConfig::SetGCDGen0GrowthMaxFactor ((int)(gc_heap::dynamic_heap_count_data.gen0_growth_soh_ratio_max * 1000.0f));
49785+ dprintf (6666, ("DATAS gen0 growth multiplier will be adjusted by %d%%, cap %.3f-%.3f, min budget %Id, max %Id",
49786+ (int)GCConfig::GetGCDGen0GrowthPercent(),
49787+ gc_heap::dynamic_heap_count_data.gen0_growth_soh_ratio_min, gc_heap::dynamic_heap_count_data.gen0_growth_soh_ratio_max,
49788+ gc_heap::dynamic_heap_count_data.min_gen0_new_allocation, gc_heap::dynamic_heap_count_data.max_gen0_new_allocation));
4974449789 }
49790+
49791+ GCConfig::SetGCDynamicAdaptationMode (gc_heap::dynamic_adaptation_mode);
4974549792#endif //DYNAMIC_HEAP_COUNT
4974649793 GCScan::GcRuntimeStructuresValid (TRUE);
4974749794
@@ -52280,13 +52327,11 @@ size_t gc_heap::get_gen0_min_size()
5228052327 gen0size = gen0size / 8 * 5;
5228152328 }
5228252329
52283- #ifdef USE_REGIONS
5228452330#ifdef STRESS_REGIONS
5228552331 // This is just so we can test allocation using more than one region on machines with very
5228652332 // small caches.
5228752333 gen0size = ((size_t)1 << min_segment_size_shr) * 3;
5228852334#endif //STRESS_REGIONS
52289- #endif //USE_REGIONS
5229052335
5229152336 gen0size = Align (gen0size);
5229252337
@@ -53883,6 +53928,8 @@ bool gc_heap::compute_memory_settings(bool is_initialization, uint32_t& nhp, uin
5388353928 m_high_memory_load_th = min ((high_memory_load_th + 5), v_high_memory_load_th);
5388453929 almost_high_memory_load_th = (high_memory_load_th > 5) ? (high_memory_load_th - 5) : 1; // avoid underflow of high_memory_load_th - 5
5388553930
53931+ GCConfig::SetGCHighMemPercent (high_memory_load_th);
53932+
5388653933 return true;
5388753934}
5388853935
0 commit comments