Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit c3e09ed

Browse files
authored
Merge pull request #6104 from Maoni0/config
Added 2 configs for Server GC
2 parents 339d991 + d088712 commit c3e09ed

File tree

5 files changed

+37
-10
lines changed

5 files changed

+37
-10
lines changed

src/gc/gc.cpp

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2266,6 +2266,8 @@ VOLATILE(BOOL) gc_heap::gc_started;
22662266

22672267
CLREvent gc_heap::gc_start_event;
22682268

2269+
bool gc_heap::gc_thread_no_affinitize_p = false;
2270+
22692271
SVAL_IMPL_NS(int, SVR, gc_heap, n_heaps);
22702272
SPTR_IMPL_NS(PTR_gc_heap, SVR, gc_heap, g_heaps);
22712273

@@ -5199,14 +5201,16 @@ bool gc_heap::create_gc_thread ()
51995201
affinity.Processor = GCThreadAffinity::None;
52005202

52015203
#if !defined(FEATURE_REDHAWK) && !defined(FEATURE_PAL)
5202-
//We are about to set affinity for GC threads, it is a good place to setup NUMA and
5203-
//CPU groups, because the process mask, processor number, group number are all
5204-
//readyly available.
5205-
if (CPUGroupInfo::CanEnableGCCPUGroups())
5206-
set_thread_group_affinity_for_heap(heap_number, &affinity);
5207-
else
5208-
set_thread_affinity_mask_for_heap(heap_number, &affinity);
5209-
5204+
if (!gc_thread_no_affinitize_p)
5205+
{
5206+
//We are about to set affinity for GC threads, it is a good place to setup NUMA and
5207+
//CPU groups, because the process mask, processor number, group number are all
5208+
//readyly available.
5209+
if (CPUGroupInfo::CanEnableGCCPUGroups())
5210+
set_thread_group_affinity_for_heap(heap_number, &affinity);
5211+
else
5212+
set_thread_affinity_mask_for_heap(heap_number, &affinity);
5213+
}
52105214
#endif // !FEATURE_REDHAWK && !FEATURE_PAL
52115215

52125216
return GCToOSInterface::CreateThread(gc_thread_stub, this, &affinity);
@@ -33673,9 +33677,18 @@ HRESULT GCHeap::Initialize ()
3367333677
gc_heap::min_segment_size = min (seg_size, large_seg_size);
3367433678

3367533679
#ifdef MULTIPLE_HEAPS
33680+
if (g_pConfig->GetGCNoAffinitize())
33681+
gc_heap::gc_thread_no_affinitize_p = true;
33682+
33683+
uint32_t nhp_from_config = g_pConfig->GetGCHeapCount();
3367633684
// GetGCProcessCpuCount only returns up to 64 procs.
33677-
unsigned nhp = CPUGroupInfo::CanEnableGCCPUGroups() ? CPUGroupInfo::GetNumActiveProcessors():
33678-
GCToOSInterface::GetCurrentProcessCpuCount();
33685+
uint32_t nhp_from_process = CPUGroupInfo::CanEnableGCCPUGroups() ?
33686+
CPUGroupInfo::GetNumActiveProcessors():
33687+
GCToOSInterface::GetCurrentProcessCpuCount();
33688+
33689+
uint32_t nhp = ((nhp_from_config == 0) ? nhp_from_process :
33690+
(min (nhp_from_config, nhp_from_process)));
33691+
3367933692
hr = gc_heap::initialize_gc (seg_size, large_seg_size /*LHEAP_ALLOC*/, nhp);
3368033693
#else
3368133694
hr = gc_heap::initialize_gc (seg_size, large_seg_size /*LHEAP_ALLOC*/);

src/gc/gcpriv.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2891,6 +2891,9 @@ class gc_heap
28912891
int gc_policy; //sweep, compact, expand
28922892

28932893
#ifdef MULTIPLE_HEAPS
2894+
PER_HEAP_ISOLATED
2895+
bool gc_thread_no_affinitize_p;
2896+
28942897
PER_HEAP_ISOLATED
28952898
CLREvent gc_start_event;
28962899

src/inc/clrconfigvalues.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,8 @@ RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(UNSUPPORTED_HeapVerify, W("HeapVerify"),
353353
RETAIL_CONFIG_STRING_INFO_EX(EXTERNAL_SetupGcCoverage, W("SetupGcCoverage"), "This doesn't appear to be a config flag", CLRConfig::REGUTIL_default)
354354
RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_GCNumaAware, W("GCNumaAware"), 1, "Specifies if to enable GC NUMA aware")
355355
RETAIL_CONFIG_DWORD_INFO(EXTERNAL_GCCpuGroup, W("GCCpuGroup"), 0, "Specifies if to enable GC to support CPU groups")
356+
RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_GCHeapCount, W("GCHeapCount"), 0, "")
357+
RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_GCNoAffinitize, W("GCNoAffinitize"), 0, "")
356358

357359
//
358360
// IBC

src/vm/eeconfig.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ HRESULT EEConfig::Init()
240240
iGCForceCompact = 0;
241241
iGCHoardVM = 0;
242242
iGCLOHCompactionMode = 0;
243+
iGCHeapCount = 0;
244+
iGCNoAffinitize = 0;
243245

244246
#ifdef GCTRIMCOMMIT
245247
iGCTrimCommit = 0;
@@ -973,6 +975,9 @@ HRESULT EEConfig::sync()
973975
#endif
974976

975977
iGCForceCompact = GetConfigDWORD_DontUse_(CLRConfig::UNSUPPORTED_gcForceCompact, iGCForceCompact);
978+
iGCNoAffinitize = Configuration::GetKnobBooleanValue(W("System.GC.NoAffinitize"),
979+
CLRConfig::UNSUPPORTED_GCNoAffinitize);
980+
iGCHeapCount = Configuration::GetKnobDWORDValue(W("System.GC.HeapCount"), CLRConfig::UNSUPPORTED_GCHeapCount);
976981

977982
fStressLog = GetConfigDWORD_DontUse_(CLRConfig::UNSUPPORTED_StressLog, fStressLog) != 0;
978983
fForceEnc = GetConfigDWORD_DontUse_(CLRConfig::UNSUPPORTED_ForceEnc, fForceEnc) != 0;

src/vm/eeconfig.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,8 @@ class EEConfig
692692
int GetGCForceCompact() const {LIMITED_METHOD_CONTRACT; return iGCForceCompact; }
693693
int GetGCRetainVM () const {LIMITED_METHOD_CONTRACT; return iGCHoardVM;}
694694
int GetGCLOHCompactionMode() const {LIMITED_METHOD_CONTRACT; return iGCLOHCompactionMode;}
695+
int GetGCHeapCount() const {LIMITED_METHOD_CONTRACT; return iGCHeapCount;}
696+
int GetGCNoAffinitize () const {LIMITED_METHOD_CONTRACT; return iGCNoAffinitize;}
695697

696698
#ifdef GCTRIMCOMMIT
697699

@@ -1077,6 +1079,8 @@ class EEConfig
10771079
int iGCForceCompact;
10781080
int iGCHoardVM;
10791081
int iGCLOHCompactionMode;
1082+
int iGCHeapCount;
1083+
int iGCNoAffinitize;
10801084

10811085
#ifdef GCTRIMCOMMIT
10821086

0 commit comments

Comments
 (0)