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

Limit min threads in thread pool to 1 #14864

Merged
merged 1 commit into from
Nov 5, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/vm/win32threadpool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ BOOL ThreadpoolMgr::SetMinThreads(DWORD MinWorkerThreads,

if (GetForceMinWorkerThreadsValue() == 0)
{
MinLimitTotalWorkerThreads = min(MinWorkerThreads, (DWORD)ThreadCounter::MaxPossibleCount);
MinLimitTotalWorkerThreads = max(1, min(MinWorkerThreads, (DWORD)ThreadCounter::MaxPossibleCount));
Copy link
Member

Choose a reason for hiding this comment

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

I assume this is how the .NET Framework behaves?

Copy link
Member Author

Choose a reason for hiding this comment

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

.NET Framework also allows 0 for the min thread count but would have the same issue. WorkerCounter's MaxWorking field is limited to this value on the low end and if it's allowed to become 0 through hill climbing thread adjustments, it triggers an assertion failure but also would require the starvation heuristic to kick in to pick up a work item. Marked for consideration for porting.


ThreadCounter::Counts counts = WorkerCounter.GetCleanCounts();
while (counts.MaxWorking < MinLimitTotalWorkerThreads)
Expand Down Expand Up @@ -647,7 +647,7 @@ BOOL ThreadpoolMgr::SetMinThreads(DWORD MinWorkerThreads,

END_SO_INTOLERANT_CODE;

MinLimitTotalCPThreads = min(MinIOCompletionThreads, (DWORD)ThreadCounter::MaxPossibleCount);
MinLimitTotalCPThreads = max(1, min(MinIOCompletionThreads, (DWORD)ThreadCounter::MaxPossibleCount));

init_result = TRUE;
}
Expand Down