@@ -44216,38 +44216,42 @@ 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);
@@ -44284,6 +44288,17 @@ void gc_heap::init_static_data()
4428444288 static_data_table[i][0].max_size = gen0_max_size;
4428544289 static_data_table[i][1].max_size = gen1_max_size;
4428644290 }
44291+
44292+ #ifdef DYNAMIC_HEAP_COUNT
44293+ if (gc_heap::dynamic_adaptation_mode == dynamic_adaptation_to_application_sizes)
44294+ {
44295+ gc_heap::dynamic_heap_count_data.min_gen0_new_allocation = gen0_min_size;
44296+ if (gen0_max_size_config)
44297+ {
44298+ gc_heap::dynamic_heap_count_data.max_gen0_new_allocation = gen0_max_size;
44299+ }
44300+ }
44301+ #endif //DYNAMIC_HEAP_COUNT
4428744302}
4428844303
4428944304bool gc_heap::init_dynamic_data()
@@ -49735,13 +49750,43 @@ HRESULT GCHeap::Initialize()
4973549750 }
4973649751 // This should be adjusted based on the target tcp. See comments in gcpriv.h
4973749752 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));
4974149753
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));
49754+ int gen0_growth_soh_ratio_percent = (int)GCConfig::GetGCDGen0GrowthPercent();
49755+ if (gen0_growth_soh_ratio_percent)
49756+ {
49757+ gc_heap::dynamic_heap_count_data.gen0_growth_soh_ratio_percent = (int)GCConfig::GetGCDGen0GrowthPercent() * 0.01f;
49758+ }
49759+ // You can specify what sizes you want to allow DATAS to stay within wrt the SOH stable size.
49760+ // By default DATAS allows 10x this size for gen0 budget when the size is small, and 0.1x when the size is large.
49761+ int gen0_growth_min_permil = (int)GCConfig::GetGCDGen0GrowthMinFactor();
49762+ int gen0_growth_max_permil = (int)GCConfig::GetGCDGen0GrowthMaxFactor();
49763+ if (gen0_growth_min_permil)
49764+ {
49765+ gc_heap::dynamic_heap_count_data.gen0_growth_soh_ratio_min = gen0_growth_min_permil * 0.001f;
49766+ }
49767+ if (gen0_growth_max_permil)
49768+ {
49769+ gc_heap::dynamic_heap_count_data.gen0_growth_soh_ratio_max = gen0_growth_max_permil * 0.001f;
49770+ }
49771+
49772+ if (gc_heap::dynamic_heap_count_data.gen0_growth_soh_ratio_min > gc_heap::dynamic_heap_count_data.gen0_growth_soh_ratio_max)
49773+ {
49774+ log_init_error_to_host ("DATAS min permil for gen0 growth %d is greater than max %d, it needs to be lower",
49775+ gc_heap::dynamic_heap_count_data.gen0_growth_soh_ratio_min, gc_heap::dynamic_heap_count_data.gen0_growth_soh_ratio_max);
49776+ return E_FAIL;
49777+ }
49778+
49779+ GCConfig::SetGCDTargetTCP ((int)gc_heap::dynamic_heap_count_data.target_tcp);
49780+ GCConfig::SetGCDGen0GrowthPercent ((int)(gc_heap::dynamic_heap_count_data.gen0_growth_soh_ratio_percent * 100.0f));
49781+ GCConfig::SetGCDGen0GrowthMinFactor ((int)(gc_heap::dynamic_heap_count_data.gen0_growth_soh_ratio_min * 1000.0f));
49782+ GCConfig::SetGCDGen0GrowthMaxFactor ((int)(gc_heap::dynamic_heap_count_data.gen0_growth_soh_ratio_max * 1000.0f));
49783+ dprintf (6666, ("DATAS gen0 growth multiplier will be adjusted by %d%%, cap %.3f-%.3f, min budget %Id, max %Id",
49784+ (int)GCConfig::GetGCDGen0GrowthPercent(),
49785+ gc_heap::dynamic_heap_count_data.gen0_growth_soh_ratio_min, gc_heap::dynamic_heap_count_data.gen0_growth_soh_ratio_max,
49786+ gc_heap::dynamic_heap_count_data.min_gen0_new_allocation, gc_heap::dynamic_heap_count_data.max_gen0_new_allocation));
4974449787 }
49788+
49789+ GCConfig::SetGCDynamicAdaptationMode (gc_heap::dynamic_adaptation_mode);
4974549790#endif //DYNAMIC_HEAP_COUNT
4974649791 GCScan::GcRuntimeStructuresValid (TRUE);
4974749792
@@ -52280,13 +52325,11 @@ size_t gc_heap::get_gen0_min_size()
5228052325 gen0size = gen0size / 8 * 5;
5228152326 }
5228252327
52283- #ifdef USE_REGIONS
5228452328#ifdef STRESS_REGIONS
5228552329 // This is just so we can test allocation using more than one region on machines with very
5228652330 // small caches.
5228752331 gen0size = ((size_t)1 << min_segment_size_shr) * 3;
5228852332#endif //STRESS_REGIONS
52289- #endif //USE_REGIONS
5229052333
5229152334 gen0size = Align (gen0size);
5229252335
@@ -53883,6 +53926,8 @@ bool gc_heap::compute_memory_settings(bool is_initialization, uint32_t& nhp, uin
5388353926 m_high_memory_load_th = min ((high_memory_load_th + 5), v_high_memory_load_th);
5388453927 almost_high_memory_load_th = (high_memory_load_th > 5) ? (high_memory_load_th - 5) : 1; // avoid underflow of high_memory_load_th - 5
5388553928
53929+ GCConfig::SetGCHighMemPercent (high_memory_load_th);
53930+
5388653931 return true;
5388753932}
5388853933
0 commit comments