About IOPriority

2010-05-13
2014-03-12
  • Starting with Vista Microsoft started to play around with the concept of IO and Page prioritize. Their main white paper is here: http://download.microsoft.com/download/a/f/7/af7777e5-7dcd-4800-8a0a-b18336565f5b/Priorityio.doc

    They already provided an implementation of the concept in the ataport.sys drivers, so as a developer you can actually use this in prioritize the disk access of your own application.

    As seen in this forum thread: http://forum.sysinternals.com/topic12767.html, they claim that
    "only the app itself can likely make intelligent decisions about when the thread(s) involved should and should not be in "background" mode"

    I respectfully disagree! I believe that developers are one of the LAST guys who should decide the prioritization of their applications. Why? Because they are selfish bastards(I know, I'm one of them). They each want their own application to run the fastest, doesn't matter if the whole system slows to a crawl.

    Since the implementation is out there already in Windows Vista / Server 2008 R2 / 7 a user with administrator right should be able to use this feature, even if officially Microsoft don't want do give this perk to their users.

    There are multiple ways to accomplish this:
    1. setting your own process to background and then starting the "victim" process - the IO Priority gets inherited
    2. using the undocumented kernel functions: NtSetInformationProcess/NtSetInformationThread
    3. getting rough and modify the memory locations of the IOPriority directly
    4. perhaps even more …

    It can be implemented in any language that supports calling WinAPI functions.

    Currently I've released binaries and sources of a very basic implementation of the idea using a console application in C#. I've chosen C# instead of C++ because you can call kernel functions without compiling "ntddk.h" using the complete-pain-in-the-ass WinDDK  build environment/tools.

    I already use this to tame my system, and to be honest I grew dependent of seeing full-hd movies play flawlessly even while there is a heavy I/O operation in progress, like copying a file or uncompressing an archive. I could simply not live without this tool anymore.

    My goal is to to expand this into a Task Manager extension (to make it easy to use by any user), and to include Page prioritization as well.

    Cheers
    Ciprian.

     
  • IO and Page priority can be currently viewed (but not set) by using Process Explorer.

     
  • Dave_Scream
    Dave_Scream
    2010-12-26

    Hi ProcessHacker now allows to change process io priority. and it can set even hight priority too….   your iopriority allows only set lowest (0) low (1) or normal (2) priorities…  why I cant set high (3) ?  process hacker allows to do it. but its not command line utility ((( so cant use it in some nnCron routines =(

     
  • Dave_Scream
    Dave_Scream
    2010-12-26

    found another command line tool. but it only works for low (1) and normal (2) priorities. http://blog.misterfoo.com/2010/07/process-priority-utility.html
    it have simple source… i can change it.. but i dont have compiler installed (((

     
  • Dave_Scream
    Dave_Scream
    2010-12-26

    allright guys.. i used this source: http://blog.misterfoo.com/2010/07/process-priority-utility.html#comment-form

    and found values for high (like in ProcessHacker) and even CRITICAL IO priority values!!!!!!!! so Im the god!

    these values are:
    0 - lowest
    1 - low
    2 - normal
    -5 - high (yes DWORD unsigned but -5 works!!!)
    -4 - critical (yes DWORD unsigned but -4 works!!!)

    i tested it in ProcessHacker - it shows CRITICAL and HIGH!

     
  • Hi dave-scream

    Thanks for your interest in this topic. Also its nice to hear that other projects have started to implement this feature too. I thought I'm the only one that cares about I/O Priority :)
    IOPriority allows to set any value, but after setting it, it reads it back and displays it. Why? Because I noticed the system will not actually accept some of the values - they silently get ignored.

    Additionally, from my practical stress tests, only two of the values produce really different behavior of the disk IO operations: lowest and normal. You may be able to set to a wider range of values, but the practical effect will be the same as one of those two values.

    My guess is that Microsoft only implemented those two in ataport.sys. Hopefully this will be taken more seriously in future releases.

    Cheers
    Ciprian.

     
  • Two years later, I'm still using this. BTW, it works fine in Windows 8 too, and I've released a new version that works with process names too, not just PIDs.

     
  • Tom Kaplan
    Tom Kaplan
    2013-12-31

    This is great! I'm a really old newbie -- I used to disassemble and modify MS-DOS 2.0 drivers for homebrew equipment, but that was in the 80s ... since them I am the prototypical "power-user" who knows enough to really screw something up but not enough to fix it.

    It took me a few minutes to figure out how to find the documentation for this utility before I realized there isn't any. Then it took a few more minutes of trial and error to figure out how to work it. So I thought I would post some rudimentary documentation for the other 47 people who have read this forum.

    DOCUMENTATION.
    This is a command line utility. To run it,

    1. Open a command line window: click "Start", in the input box labeled "search program and files," type "cmd" and press enter.

    2. Navigate to the directory where you downloaded iopriorityv1.1.exe. For example on my PC I would type "CD \users\tpkaplan\downloads".

    3. Run the program by typing "iopriorityv1.1 [process name] [value]". For example, to set the IO priority of "notepad.exe" to 0 (the lowest priority), you would type "iopriorityv1.1 notepad 0"

    Detailed Usage:

    iopriorityv1.1 [Process Name|Process ID (aka PID)] [Value]

    Sets the IO priority for specified process to Value. Acceptable values are:
    0 - lowest
    1 - low
    2 - normal
    -5 - high
    -4 - critical

    Notes.

    1. Quotation marks for Process Name are mandatory if the name is more than one word, optional for process names that are one word.

    2. If a process name appears as "OUTLOOK.EXE *32" in Windows Task Manager, then the process name is "OUTLOOK".

    3. You can use either the Process ID (aka PID) or the Process Name. PID is a 4 digit number which appears in Task Manager for some services on the "Services" tab. I'm not sure why it doesn't show numbers for other services or for processes. (anyone?)

    ALSO - one of the other downfalls of being a newb - is the source code posted somewhere that I just can't find? Or is it "available on request"?