patternsqlModerate
Prevent THREADPOOL waits due to idle worker thread trimming
Viewed 0 times
preventduethreadpoolwaitstrimmingworkerthreadidle
Problem
After reading Unusual THREADPOOL Waits by Josh Darnell, a Twitter user mentioned there is an undocumented trace flag to prevent trimming idle workers:
The idea is that once SQL Server has created enough threads to service the peak workload, it should not then trim worker threads (release them to the OS) after 15 minutes or so of them not being needed.
The idle worker threads will continue to use resources (e.g. memory) but there will not be the burst of
What is this undocumented trace flag, and how does it work?
The idea is that once SQL Server has created enough threads to service the peak workload, it should not then trim worker threads (release them to the OS) after 15 minutes or so of them not being needed.
The idle worker threads will continue to use resources (e.g. memory) but there will not be the burst of
THREADPOOL waits when more workers are suddenly required. Apparently this can be of assistance when using Always On Availability Groups.What is this undocumented trace flag, and how does it work?
Solution
The trace flag is 8061.
It is undocumented, so should only be enabled when suggested by Microsoft support.
The flag needs to be enabled globally (or on start up):
SQL Server checks to see if it should trim idle workers in:
It skips routine excess worker trimming if trace flag 8061 is set.
Worker trimming is performed by:
Worker trimming will still be performed if the following memory value is greater than zero:
Quite rightly, the trace flag will not prevent trimming under all scenarios, but it does work for the purpose expressed in the question.
It is undocumented, so should only be enabled when suggested by Microsoft support.
The flag needs to be enabled globally (or on start up):
-- Enable globally
DBCC TRACEON (8061, -1);SQL Server checks to see if it should trim idle workers in:
sqldk!SchedulerMonitor::CheckSchedulerIt skips routine excess worker trimming if trace flag 8061 is set.
Worker trimming is performed by:
sqldk!WorkDispatcher::TrimIdleWorkersWorker trimming will still be performed if the following memory value is greater than zero:
sqldk!SOS_OS::sm_WorkerPressureCountQuite rightly, the trace flag will not prevent trimming under all scenarios, but it does work for the purpose expressed in the question.
Code Snippets
-- Enable globally
DBCC TRACEON (8061, -1);sqldk!SchedulerMonitor::CheckSchedulersqldk!WorkDispatcher::TrimIdleWorkerssqldk!SOS_OS::sm_WorkerPressureCountContext
StackExchange Database Administrators Q#274612, answer score: 14
Revisions (0)
No revisions yet.