Thoughts from the EPS Windows Server Performance Team
Useful Microsoft Blogs
Good morning AskPerf! If you’ve used Task Manager, you may have noticed that it allows setting an “instance-based priority”. This is an option where you can choose to boost or reduce the priority of any process, whereby adjusting the amount of CPU attention the process receives. But honestly, how many times have you used this feature for any business apps on your Workstations or Servers? The answer is probably not much. The default CPU scheduling algorithm is adequately designed to distribute CPU among running processes in most scenarios.
So recently, one of our customers reported the following anomaly they saw in Task Manager:
About 70% of the running processes would launch as Normal, and within few seconds the priority would change to Above normal automatically. This would happen for many arbitrary processes, and would not allow a fair CPU scheduling for LOB applications.
So how do you drill it down? Well, we need to check some basic settings first. Any process on Windows platform can have one of the following priorities at a given time:
Per MSDN these priorities correspond to following classes:
A process always launches with its Base Priority (default) – which can be decided by the app developer – else will inherit to default NORMAL_PRIORITY_CLASS.
If you are a developer, to adjust your process’ priority from Base Priority (to newer priority), you can use the SetPriorityClass function. That is exactly what happens for a running process’s instance when you opt to adjust its priority from Task Manager. So we followed that route and begin investigating who is calling this SetPriorityClass() function on affected machine. We used our best friend XPERF (rather WPR, the latest version of it) with stackwalk enabled.
In WPA, we focused on the stack flow for the process in question (notepad.exe in our example), and found below the stack where we see wsrm.exe calling SetPriorityClass() function. You can see this stack using just our public symbols (path: http://msdl.microsoft.com/download/symbols).
| | |- wsrm.exe!CCPUManager::UpdatePriorities
| | | wsrm.exe!CCPUManager::UpdatePriorities
| | | |- wsrm.exe!CProcess::SetPriorityClass
| | | | KernelBase.dll!SetPriorityClass
From screenshot of Windows Performance Analyzer:
So now we know what is causing the priorities to be bumped up, but why?
Windows Server Resource Manager (wsrm.exe) is a great tool to manage server processor and memory usage with standard or custom resource policies. If you find yourself in a similar situation, chances are that you need to review the WSRM configuration and policies in your environment. Or, you can simply disable WSRM if you are not using it. This blog discusses more about WSRM policies and configuration.
BONUS: Task Scheduler launches tasks by default in Below normal priority. To change the priority of a task, you would have to edit its xml file (<Priority>7</Priority>), and re-import it. More info: TaskSettings.Priority property
Nice one, thanks. Did you used the default WPR option (performance scenario: general, detail level: verbose) or did you selected any resource/scenario analysis available in the WPR profiles option?
Wht did not you use WPR and prefered XPERF?
The default WPR (General) is good enough. What matters if that you should be able to see the stack and functions being resolved. Which means 'Disable Paging Executive' + General WPR + Rightly configured public symbols - and you have it!
@Gregory Suvalian: Indeed I used WPR, please refer repro steps. BTW, WPR uses Xperf.exe in the background.
Just a little typo: Its "Windows System Resource Manager", not "Windows Server Resource Manager"