The case of “Above normal” priority

The case of “Above normal” priority

  • Comments 5
  • Likes

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:

clip_image001

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:

  • Realtime
  • High
  • Above normal
  • Normal
  • Below normal
  • Low

clip_image002

Per MSDN these priorities correspond to following classes:

  • IDLE_PRIORITY_CLASS
  • BELOW_NORMAL_PRIORITY_CLASS
  • NORMAL_PRIORITY_CLASS
  • ABOVE_NORMAL_PRIORITY_CLASS
  • HIGH_PRIORITY_CLASS
  • REALTIME_PRIORITY_CLASS

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.

Steps:

  1. Start WPR
  2. Launch a process (say, notepad.exe)
  3. Wait for few seconds till the priority gets raised from “Normal” to “Above normal”
  4. Stop WPR capture
  5. Load the output ETL file in WPA (Windows Performance Analyzer, tool that comes with WPR installation)

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).

Line #

Process

Stack

Weight

All Count

28

 

|    |    |- wsrm.exe!CCPUManager::UpdatePriorities

4.891726

5

29

 

|    |    |    wsrm.exe!CCPUManager::UpdatePriorities

4.891726

5

30

 

|    |    |    wsrm.exe!CCPUManager::UpdatePriorities

4.891726

5

31

 

|    |    |    |- wsrm.exe!CProcess::SetPriorityClass

4.058269

4

32

 

|    |    |    |    KernelBase.dll!SetPriorityClass

4.058269

4

From screenshot of Windows Performance Analyzer:

clip_image003

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.

Additional Resources

Scheduling Priorities

-Deepak

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

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • 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"