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

Commit

Permalink
Merge pull request #6104 from Maoni0/config
Browse files Browse the repository at this point in the history
Added 2 configs for Server GC
  • Loading branch information
Maoni0 authored Jul 3, 2016
2 parents 339d991 + d088712 commit c3e09ed
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 10 deletions.
33 changes: 23 additions & 10 deletions src/gc/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2266,6 +2266,8 @@ VOLATILE(BOOL) gc_heap::gc_started;

CLREvent gc_heap::gc_start_event;

bool gc_heap::gc_thread_no_affinitize_p = false;

SVAL_IMPL_NS(int, SVR, gc_heap, n_heaps);
SPTR_IMPL_NS(PTR_gc_heap, SVR, gc_heap, g_heaps);

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

#if !defined(FEATURE_REDHAWK) && !defined(FEATURE_PAL)
//We are about to set affinity for GC threads, it is a good place to setup NUMA and
//CPU groups, because the process mask, processor number, group number are all
//readyly available.
if (CPUGroupInfo::CanEnableGCCPUGroups())
set_thread_group_affinity_for_heap(heap_number, &affinity);
else
set_thread_affinity_mask_for_heap(heap_number, &affinity);

if (!gc_thread_no_affinitize_p)
{
//We are about to set affinity for GC threads, it is a good place to setup NUMA and
//CPU groups, because the process mask, processor number, group number are all
//readyly available.
if (CPUGroupInfo::CanEnableGCCPUGroups())
set_thread_group_affinity_for_heap(heap_number, &affinity);
else
set_thread_affinity_mask_for_heap(heap_number, &affinity);
}
#endif // !FEATURE_REDHAWK && !FEATURE_PAL

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

#ifdef MULTIPLE_HEAPS
if (g_pConfig->GetGCNoAffinitize())
gc_heap::gc_thread_no_affinitize_p = true;

uint32_t nhp_from_config = g_pConfig->GetGCHeapCount();
// GetGCProcessCpuCount only returns up to 64 procs.
unsigned nhp = CPUGroupInfo::CanEnableGCCPUGroups() ? CPUGroupInfo::GetNumActiveProcessors():
GCToOSInterface::GetCurrentProcessCpuCount();
uint32_t nhp_from_process = CPUGroupInfo::CanEnableGCCPUGroups() ?
CPUGroupInfo::GetNumActiveProcessors():
GCToOSInterface::GetCurrentProcessCpuCount();

uint32_t nhp = ((nhp_from_config == 0) ? nhp_from_process :
(min (nhp_from_config, nhp_from_process)));

hr = gc_heap::initialize_gc (seg_size, large_seg_size /*LHEAP_ALLOC*/, nhp);
#else
hr = gc_heap::initialize_gc (seg_size, large_seg_size /*LHEAP_ALLOC*/);
Expand Down
3 changes: 3 additions & 0 deletions src/gc/gcpriv.h
Original file line number Diff line number Diff line change
Expand Up @@ -2891,6 +2891,9 @@ class gc_heap
int gc_policy; //sweep, compact, expand

#ifdef MULTIPLE_HEAPS
PER_HEAP_ISOLATED
bool gc_thread_no_affinitize_p;

PER_HEAP_ISOLATED
CLREvent gc_start_event;

Expand Down
2 changes: 2 additions & 0 deletions src/inc/clrconfigvalues.h
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,8 @@ RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(UNSUPPORTED_HeapVerify, W("HeapVerify"),
RETAIL_CONFIG_STRING_INFO_EX(EXTERNAL_SetupGcCoverage, W("SetupGcCoverage"), "This doesn't appear to be a config flag", CLRConfig::REGUTIL_default)
RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_GCNumaAware, W("GCNumaAware"), 1, "Specifies if to enable GC NUMA aware")
RETAIL_CONFIG_DWORD_INFO(EXTERNAL_GCCpuGroup, W("GCCpuGroup"), 0, "Specifies if to enable GC to support CPU groups")
RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_GCHeapCount, W("GCHeapCount"), 0, "")
RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_GCNoAffinitize, W("GCNoAffinitize"), 0, "")

//
// IBC
Expand Down
5 changes: 5 additions & 0 deletions src/vm/eeconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ HRESULT EEConfig::Init()
iGCForceCompact = 0;
iGCHoardVM = 0;
iGCLOHCompactionMode = 0;
iGCHeapCount = 0;
iGCNoAffinitize = 0;

#ifdef GCTRIMCOMMIT
iGCTrimCommit = 0;
Expand Down Expand Up @@ -973,6 +975,9 @@ HRESULT EEConfig::sync()
#endif

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

fStressLog = GetConfigDWORD_DontUse_(CLRConfig::UNSUPPORTED_StressLog, fStressLog) != 0;
fForceEnc = GetConfigDWORD_DontUse_(CLRConfig::UNSUPPORTED_ForceEnc, fForceEnc) != 0;
Expand Down
4 changes: 4 additions & 0 deletions src/vm/eeconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,8 @@ class EEConfig
int GetGCForceCompact() const {LIMITED_METHOD_CONTRACT; return iGCForceCompact; }
int GetGCRetainVM () const {LIMITED_METHOD_CONTRACT; return iGCHoardVM;}
int GetGCLOHCompactionMode() const {LIMITED_METHOD_CONTRACT; return iGCLOHCompactionMode;}
int GetGCHeapCount() const {LIMITED_METHOD_CONTRACT; return iGCHeapCount;}
int GetGCNoAffinitize () const {LIMITED_METHOD_CONTRACT; return iGCNoAffinitize;}

#ifdef GCTRIMCOMMIT

Expand Down Expand Up @@ -1077,6 +1079,8 @@ class EEConfig
int iGCForceCompact;
int iGCHoardVM;
int iGCLOHCompactionMode;
int iGCHeapCount;
int iGCNoAffinitize;

#ifdef GCTRIMCOMMIT

Expand Down

0 comments on commit c3e09ed

Please sign in to comment.