From ead0eebfd6580f49a26e1a7ef75fa663a19d4984 Mon Sep 17 00:00:00 2001 From: mrsharm Date: Fri, 31 Mar 2023 19:27:42 -0700 Subject: [PATCH 1/7] Added setting the GCHighMemPercent so that it's reported by the Configuration API --- src/coreclr/gc/gc.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/coreclr/gc/gc.cpp b/src/coreclr/gc/gc.cpp index a85d28eb6a7396..aa231eb4027dac 100644 --- a/src/coreclr/gc/gc.cpp +++ b/src/coreclr/gc/gc.cpp @@ -45586,6 +45586,8 @@ HRESULT GCHeap::Initialize() gc_heap::v_high_memory_load_th = 97; } + GCConfig::SetGCHighMemPercent(highmem_th_from_config); + gc_heap::m_high_memory_load_th = min ((gc_heap::high_memory_load_th + 5), gc_heap::v_high_memory_load_th); gc_heap::pm_stress_on = (GCConfig::GetGCProvModeStress() != 0); From 07676e42f8f618df3bf9fe4bdf12d3c2cadb28b5 Mon Sep 17 00:00:00 2001 From: mrsharm Date: Mon, 3 Apr 2023 09:44:31 -0700 Subject: [PATCH 2/7] Added all but the string based properties --- src/coreclr/gc/gc.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/coreclr/gc/gc.cpp b/src/coreclr/gc/gc.cpp index aa231eb4027dac..c95fc9fcdbfb98 100644 --- a/src/coreclr/gc/gc.cpp +++ b/src/coreclr/gc/gc.cpp @@ -14053,6 +14053,7 @@ gc_heap::init_semi_shared() if (conserve_mem_setting > 9) conserve_mem_setting = 9; + GCConfig::SetGCConserveMem(conserve_mem_setting); dprintf (1, ("conserve_mem_setting = %d", conserve_mem_setting)); reset_mm_p = TRUE; @@ -45360,6 +45361,9 @@ HRESULT GCHeap::Initialize() #endif //USE_REGIONS #endif //HOST_64BIT + + GCConfig::SetRetainVM(GCConfig::GetRetainVM()); + GCConfig::SetGCHeapHardLimitPercent(GCConfig::GetGCHeapHardLimitPercent()); GCConfig::SetGCLargePages(gc_heap::use_large_pages_p); uint32_t nhp = 1; @@ -45415,6 +45419,8 @@ HRESULT GCHeap::Initialize() gc_heap::gc_thread_no_affinitize_p = (gc_heap::heap_hard_limit ? !affinity_config_specified_p : (GCConfig::GetNoAffinitize() != 0)); + GCConfig::SetNoAffinitize(GCConfig::GetNoAffinitize()); + if (!(gc_heap::gc_thread_no_affinitize_p)) { uint32_t num_affinitized_processors = (uint32_t)process_affinity_set->Count(); @@ -45550,6 +45556,10 @@ HRESULT GCHeap::Initialize() GCConfig::SetGCHeapHardLimitLOH(static_cast(gc_heap::heap_hard_limit_oh[loh])); GCConfig::SetGCHeapHardLimitPOH(static_cast(gc_heap::heap_hard_limit_oh[poh])); + GCConfig::SetGCHeapHardLimitSOHPercent(GCConfig::GetGCHeapHardLimitSOHPercent()); + GCConfig::SetGCHeapHardLimitLOHPercent(GCConfig::GetGCHeapHardLimitLOHPercent()); + GCConfig::SetGCHeapHardLimitPOHPercent(GCConfig::GetGCHeapHardLimitPOHPercent()); + if (hr != S_OK) return hr; From d90e1ecdabe23eb18305f43316bd06288cc97878 Mon Sep 17 00:00:00 2001 From: mrsharm Date: Mon, 3 Apr 2023 11:34:16 -0700 Subject: [PATCH 3/7] Fix for the correct variable set for the Configuration API --- src/coreclr/gc/gc.cpp | 10 ---------- src/coreclr/gc/gcconfig.cpp | 6 ++++-- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/coreclr/gc/gc.cpp b/src/coreclr/gc/gc.cpp index c95fc9fcdbfb98..674c598744edf8 100644 --- a/src/coreclr/gc/gc.cpp +++ b/src/coreclr/gc/gc.cpp @@ -45362,8 +45362,6 @@ HRESULT GCHeap::Initialize() #endif //HOST_64BIT - GCConfig::SetRetainVM(GCConfig::GetRetainVM()); - GCConfig::SetGCHeapHardLimitPercent(GCConfig::GetGCHeapHardLimitPercent()); GCConfig::SetGCLargePages(gc_heap::use_large_pages_p); uint32_t nhp = 1; @@ -45419,8 +45417,6 @@ HRESULT GCHeap::Initialize() gc_heap::gc_thread_no_affinitize_p = (gc_heap::heap_hard_limit ? !affinity_config_specified_p : (GCConfig::GetNoAffinitize() != 0)); - GCConfig::SetNoAffinitize(GCConfig::GetNoAffinitize()); - if (!(gc_heap::gc_thread_no_affinitize_p)) { uint32_t num_affinitized_processors = (uint32_t)process_affinity_set->Count(); @@ -45556,10 +45552,6 @@ HRESULT GCHeap::Initialize() GCConfig::SetGCHeapHardLimitLOH(static_cast(gc_heap::heap_hard_limit_oh[loh])); GCConfig::SetGCHeapHardLimitPOH(static_cast(gc_heap::heap_hard_limit_oh[poh])); - GCConfig::SetGCHeapHardLimitSOHPercent(GCConfig::GetGCHeapHardLimitSOHPercent()); - GCConfig::SetGCHeapHardLimitLOHPercent(GCConfig::GetGCHeapHardLimitLOHPercent()); - GCConfig::SetGCHeapHardLimitPOHPercent(GCConfig::GetGCHeapHardLimitPOHPercent()); - if (hr != S_OK) return hr; @@ -45596,8 +45588,6 @@ HRESULT GCHeap::Initialize() gc_heap::v_high_memory_load_th = 97; } - GCConfig::SetGCHighMemPercent(highmem_th_from_config); - gc_heap::m_high_memory_load_th = min ((gc_heap::high_memory_load_th + 5), gc_heap::v_high_memory_load_th); gc_heap::pm_stress_on = (GCConfig::GetGCProvModeStress() != 0); diff --git a/src/coreclr/gc/gcconfig.cpp b/src/coreclr/gc/gcconfig.cpp index 9957e43dc5c5db..1225355dcd2781 100644 --- a/src/coreclr/gc/gcconfig.cpp +++ b/src/coreclr/gc/gcconfig.cpp @@ -65,10 +65,12 @@ GC_CONFIGURATION_KEYS void GCConfig::Initialize() { #define BOOL_CONFIG(name, private_key, public_key, unused_default, unused_doc) \ - s_##name##Provided = GCToEEInterface::GetBooleanConfigValue(private_key, public_key, &s_##name); + s_Updated##name = s_##name##Provided = GCToEEInterface::GetBooleanConfigValue(private_key, public_key, &s_##name); + #define INT_CONFIG(name, private_key, public_key, unused_default, unused_doc) \ - GCToEEInterface::GetIntConfigValue(private_key, public_key, &s_##name); + GCToEEInterface::GetIntConfigValue(private_key, public_key, &s_##name); \ + s_Updated##name = s_##name; #define STRING_CONFIG(unused_name, unused_private_key, unused_public_key, unused_doc) From fcbfdd86a60bae3ba744d6c5f45a7da5bc80ce07 Mon Sep 17 00:00:00 2001 From: mrsharm Date: Mon, 3 Apr 2023 11:38:35 -0700 Subject: [PATCH 4/7] Removed redunant changes --- src/coreclr/gc/gc.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/coreclr/gc/gc.cpp b/src/coreclr/gc/gc.cpp index 674c598744edf8..a85d28eb6a7396 100644 --- a/src/coreclr/gc/gc.cpp +++ b/src/coreclr/gc/gc.cpp @@ -14053,7 +14053,6 @@ gc_heap::init_semi_shared() if (conserve_mem_setting > 9) conserve_mem_setting = 9; - GCConfig::SetGCConserveMem(conserve_mem_setting); dprintf (1, ("conserve_mem_setting = %d", conserve_mem_setting)); reset_mm_p = TRUE; @@ -45361,7 +45360,6 @@ HRESULT GCHeap::Initialize() #endif //USE_REGIONS #endif //HOST_64BIT - GCConfig::SetGCLargePages(gc_heap::use_large_pages_p); uint32_t nhp = 1; From 864211fe0c96590f23b9c69c2fe7d0648646a491 Mon Sep 17 00:00:00 2001 From: mrsharm Date: Tue, 4 Apr 2023 12:34:56 -0700 Subject: [PATCH 5/7] Added the SetGCRegionRange for the regions range --- src/coreclr/gc/gc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/coreclr/gc/gc.cpp b/src/coreclr/gc/gc.cpp index a85d28eb6a7396..d196609aca54ef 100644 --- a/src/coreclr/gc/gc.cpp +++ b/src/coreclr/gc/gc.cpp @@ -45356,7 +45356,8 @@ HRESULT GCHeap::Initialize() } gc_heap::regions_range = align_on_page(gc_heap::regions_range); } - // TODO: Set config after config API is merged. + + GCConfig::SetGCRegionRange(gc_heap::regions_range); #endif //USE_REGIONS #endif //HOST_64BIT From 0febcd1135597bae80acba1a5ccbfe4123ff13bd Mon Sep 17 00:00:00 2001 From: mrsharm Date: Tue, 4 Apr 2023 14:20:35 -0700 Subject: [PATCH 6/7] Fixed issue with correctly setting the name --- src/coreclr/gc/gcconfig.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/coreclr/gc/gcconfig.cpp b/src/coreclr/gc/gcconfig.cpp index 1225355dcd2781..366fa0e8efb465 100644 --- a/src/coreclr/gc/gcconfig.cpp +++ b/src/coreclr/gc/gcconfig.cpp @@ -64,10 +64,10 @@ GC_CONFIGURATION_KEYS void GCConfig::Initialize() { -#define BOOL_CONFIG(name, private_key, public_key, unused_default, unused_doc) \ - s_Updated##name = s_##name##Provided = GCToEEInterface::GetBooleanConfigValue(private_key, public_key, &s_##name); +#define BOOL_CONFIG(name, private_key, public_key, unused_default, unused_doc) \ + s_##name##Provided = GCToEEInterface::GetBooleanConfigValue(private_key, public_key, &s_##name); \ + s_Updated##name = s_##name; - #define INT_CONFIG(name, private_key, public_key, unused_default, unused_doc) \ GCToEEInterface::GetIntConfigValue(private_key, public_key, &s_##name); \ s_Updated##name = s_##name; From 4726f1012b4dd46062a0e0792570f695d36bc2c1 Mon Sep 17 00:00:00 2001 From: mrsharm Date: Tue, 4 Apr 2023 17:53:27 -0700 Subject: [PATCH 7/7] Added consistency to the INT_CONFIG class --- src/coreclr/gc/gcconfig.cpp | 11 ++++++++--- src/coreclr/gc/gcconfig.h | 4 +++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/coreclr/gc/gcconfig.cpp b/src/coreclr/gc/gcconfig.cpp index 366fa0e8efb465..6112b1edc8b446 100644 --- a/src/coreclr/gc/gcconfig.cpp +++ b/src/coreclr/gc/gcconfig.cpp @@ -18,8 +18,13 @@ #define INT_CONFIG(name, unused_private_key, unused_public_key, default, unused_doc) \ int64_t GCConfig::Get##name() { return s_##name; } \ + int64_t GCConfig::Get##name(int64_t defaultValue) \ + { \ + return s_##name##Provided ? s_##name : defaultValue; \ + } \ void GCConfig::Set##name(int64_t value) { s_Updated##name = value; } \ int64_t GCConfig::s_##name = default; \ + bool GCConfig::s_##name##Provided = false; \ int64_t GCConfig::s_Updated##name = default; // String configs are not cached because 1) they are rare and @@ -68,9 +73,9 @@ void GCConfig::Initialize() s_##name##Provided = GCToEEInterface::GetBooleanConfigValue(private_key, public_key, &s_##name); \ s_Updated##name = s_##name; -#define INT_CONFIG(name, private_key, public_key, unused_default, unused_doc) \ - GCToEEInterface::GetIntConfigValue(private_key, public_key, &s_##name); \ - s_Updated##name = s_##name; +#define INT_CONFIG(name, private_key, public_key, unused_default, unused_doc) \ + s_##name##Provided = GCToEEInterface::GetIntConfigValue(private_key, public_key, &s_##name); \ + s_Updated##name = s_##name; \ #define STRING_CONFIG(unused_name, unused_private_key, unused_public_key, unused_doc) diff --git a/src/coreclr/gc/gcconfig.h b/src/coreclr/gc/gcconfig.h index 2b5f87b41f4cc3..20338a35ec0e4a 100644 --- a/src/coreclr/gc/gcconfig.h +++ b/src/coreclr/gc/gcconfig.h @@ -151,9 +151,11 @@ class GCConfig #define INT_CONFIG(name, unused_private_key, unused_public_key, unused_default, unused_doc) \ public: static int64_t Get##name(); \ + public: static int64_t Get##name(int64_t defaultValue); \ public: static void Set##name(int64_t value); \ private: static int64_t s_##name; \ - private: static int64_t s_Updated##name; + private: static bool s_##name##Provided; \ + private: static int64_t s_Updated##name; \ #define STRING_CONFIG(name, unused_private_key, unused_public_key, unused_doc) \ public: static GCConfigStringHolder Get##name();