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

Improve support for --cpus to Docker CLI #23398

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/gc/env/gcenv.os.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ class GCToOSInterface
// Get number of processors assigned to the current process
// Return:
// The number of processors
static uint32_t GetCurrentProcessCpuCount();
static uint32_t GetCurrentProcessCpuCount(bool withCpuLimit = false);

// Sets the calling thread's affinity to only run on the processor specified.
// Parameters:
Expand Down
2 changes: 1 addition & 1 deletion src/gc/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34103,7 +34103,7 @@ HRESULT GCHeap::Initialize()

nhp_from_config = static_cast<uint32_t>(GCConfig::GetHeapCount());

uint32_t nhp_from_process = GCToOSInterface::GetCurrentProcessCpuCount();
uint32_t nhp_from_process = GCToOSInterface::GetCurrentProcessCpuCount(true);

if (nhp_from_config)
{
Expand Down
2 changes: 1 addition & 1 deletion src/gc/windows/gcenv.windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,7 @@ const AffinitySet* GCToOSInterface::SetGCThreadsAffinitySet(uintptr_t configAffi
// Get number of processors assigned to the current process
// Return:
// The number of processors
uint32_t GCToOSInterface::GetCurrentProcessCpuCount()
uint32_t GCToOSInterface::GetCurrentProcessCpuCount(bool withCpuLimit)
{
static int cCPUs = 0;

Expand Down
2 changes: 1 addition & 1 deletion src/inc/utilcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -1413,7 +1413,7 @@ class CPUGroupInfo
}
};

int GetCurrentProcessCpuCount();
int GetCurrentProcessCpuCount(bool withCpuLimit = false);
DWORD_PTR GetCurrentProcessCpuMask();

uint32_t GetOsPageSize();
Expand Down
4 changes: 2 additions & 2 deletions src/utilcode/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,7 @@ BOOL CPUGroupInfo::GetCPUGroupRange(WORD group_number, WORD* group_begin, WORD*
//******************************************************************************
// Returns the number of processors that a process has been configured to run on
//******************************************************************************
int GetCurrentProcessCpuCount()
int GetCurrentProcessCpuCount(bool withCpuLimit)
{
CONTRACTL
{
Expand Down Expand Up @@ -1236,7 +1236,7 @@ int GetCurrentProcessCpuCount()
#ifdef FEATURE_PAL
uint32_t cpuLimit;

if (PAL_GetCpuLimit(&cpuLimit) && cpuLimit < count)
if (withCpuLimit && PAL_GetCpuLimit(&cpuLimit) && cpuLimit < count)
count = cpuLimit;
#endif

Expand Down
4 changes: 2 additions & 2 deletions src/vm/gcenv.os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,14 +476,14 @@ const AffinitySet* GCToOSInterface::SetGCThreadsAffinitySet(uintptr_t configAffi
// Get number of processors assigned to the current process
// Return:
// The number of processors
uint32_t GCToOSInterface::GetCurrentProcessCpuCount()
uint32_t GCToOSInterface::GetCurrentProcessCpuCount(bool withCpuLimit)
{
LIMITED_METHOD_CONTRACT;

// GetCurrentProcessCpuCount only returns up to 64 procs.
return CPUGroupInfo::CanEnableGCCPUGroups() ?
GCToOSInterface::GetTotalProcessorCount():
::GetCurrentProcessCpuCount();
::GetCurrentProcessCpuCount(withCpuLimit);
}

// Return the size of the user-mode portion of the virtual address space of this process.
Expand Down
3 changes: 2 additions & 1 deletion src/vm/simplerwlock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ class SimpleRWLock
} CONTRACTL_END;

m_RWLock = 0;
m_spinCount = (GetCurrentProcessCpuCount() == 1) ? 0 : 4000;
// Passing false here reduces ASP.NET Core Plaintext benchmark results from 1.2M to 0.8M RPS.
Copy link
Member

@jkotas jkotas Apr 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious - where (stacktrace) does the ASP.NET Core Plaintext take this lock?

m_spinCount = (GetCurrentProcessCpuCount(true) == 1) ? 0 : 4000;
m_WriterWaiting = FALSE;

#ifdef _DEBUG
Expand Down