@@ -44216,38 +44216,42 @@ void gc_heap::init_static_data()
44216
44216
{
44217
44217
size_t gen0_min_size = get_gen0_min_size();
44218
44218
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;
44240
44220
44241
44221
size_t gen0_max_size_config = (size_t)GCConfig::GetGCGen0MaxBudget();
44242
44222
44243
44223
if (gen0_max_size_config)
44244
44224
{
44245
- gen0_max_size = min (gen0_max_size, gen0_max_size_config) ;
44225
+ gen0_max_size = gen0_max_size_config;
44246
44226
44247
44227
#ifdef FEATURE_EVENT_TRACE
44248
44228
gen0_max_budget_from_config = gen0_max_size;
44249
44229
#endif //FEATURE_EVENT_TRACE
44250
44230
}
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
+ }
44251
44255
44252
44256
gen0_max_size = Align (gen0_max_size);
44253
44257
gen0_min_size = min (gen0_min_size, gen0_max_size);
@@ -44284,6 +44288,17 @@ void gc_heap::init_static_data()
44284
44288
static_data_table[i][0].max_size = gen0_max_size;
44285
44289
static_data_table[i][1].max_size = gen1_max_size;
44286
44290
}
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
44287
44302
}
44288
44303
44289
44304
bool gc_heap::init_dynamic_data()
@@ -49735,13 +49750,43 @@ HRESULT GCHeap::Initialize()
49735
49750
}
49736
49751
// This should be adjusted based on the target tcp. See comments in gcpriv.h
49737
49752
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));
49741
49753
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));
49744
49787
}
49788
+
49789
+ GCConfig::SetGCDynamicAdaptationMode (gc_heap::dynamic_adaptation_mode);
49745
49790
#endif //DYNAMIC_HEAP_COUNT
49746
49791
GCScan::GcRuntimeStructuresValid (TRUE);
49747
49792
@@ -52280,13 +52325,11 @@ size_t gc_heap::get_gen0_min_size()
52280
52325
gen0size = gen0size / 8 * 5;
52281
52326
}
52282
52327
52283
- #ifdef USE_REGIONS
52284
52328
#ifdef STRESS_REGIONS
52285
52329
// This is just so we can test allocation using more than one region on machines with very
52286
52330
// small caches.
52287
52331
gen0size = ((size_t)1 << min_segment_size_shr) * 3;
52288
52332
#endif //STRESS_REGIONS
52289
- #endif //USE_REGIONS
52290
52333
52291
52334
gen0size = Align (gen0size);
52292
52335
@@ -53883,6 +53926,8 @@ bool gc_heap::compute_memory_settings(bool is_initialization, uint32_t& nhp, uin
53883
53926
m_high_memory_load_th = min ((high_memory_load_th + 5), v_high_memory_load_th);
53884
53927
almost_high_memory_load_th = (high_memory_load_th > 5) ? (high_memory_load_th - 5) : 1; // avoid underflow of high_memory_load_th - 5
53885
53928
53929
+ GCConfig::SetGCHighMemPercent (high_memory_load_th);
53930
+
53886
53931
return true;
53887
53932
}
53888
53933
0 commit comments