Menu

About IOPriority

2010-05-13
2019-05-18
  • Ciprian Csordas

    Ciprian Csordas - 2010-05-13

    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.

     
  • Ciprian Csordas

    Ciprian Csordas - 2010-05-13

    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!

     
  • Ciprian Csordas

    Ciprian Csordas - 2011-02-17

    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.

     
  • Ciprian Csordas

    Ciprian Csordas - 2012-12-28

    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"?

     
  • Ciprian Csordas

    Ciprian Csordas - 2014-03-12

    Thank you for the documentation, Tom.

    The full sources (Visual Studio solution) was always available in the files section:
    http://sourceforge.net/projects/iopriority/files/Simple%20Console/IOPriority.zip/download

     
    • kilves76

      kilves76 - 2019-05-18

      Would be nice if it'd take a multiple argument list so that many io priorities could be set once, just as-is or comma separated, iopriority name/pid #, name/pid #, ...

      Even better if one could set the process priority too, so that one not need to use wmic/other tools for that. It'd be compatible with existing scripts with syntax like
      iopriority name/pid iopriority processpriority , [multi]

      Extra bonus if you'd incorporate services prioritization too, currently i have to parse the output of tasklist /fi "SERVICES eq ServiceName" /nh /fo table to get the PID, an then set the priority with wmic process where Name="%%P" CALL setpriority "above normal", it's a very slow kludge.

      It'd be awesome if one command line tool could do this all , would shrink scripts like my system monitor/adjuster 90% or more, i now have closer to 100 lines of script (despite using loops for multiple parameters wherever possible) which could be replaced with just one line with multiple parameters for io and priority for programs/services.

       
  • TimG

    TimG - 2015-02-21

    I tried to use IOPriority v 1.1 to lower the disk priority of Beyond Compare (Scooter Software).
    The Windows Tasklist output includes this:
    BCompare.exe 3448 Console 1 28,176 K

    IOPriority doesn't seem to recognize the task by name:

    C:>IOPriorityV1.1.exe BCompare.exe 1
    That is too ugly to be a PID, hopefully its a process name.
    Unhandled Exception: System.Exception: No process found with that name: BCompare.exe
    at IOPriority.Program.initArgs(String[] args)
    at IOPriority.Program.Main(String[] args)

    It works OK using PID:

    C:>IOPriorityV1.1.exe 3448 1
    new IOPrio: 1

    Is there a different way to provide the process name that is expected?

     
  • Jack Wallace

    Jack Wallace - 2015-03-10

    I downloaded IOPriority 1.1 and find it helpful. The version on sourceforge does not seem to accept a prio other than 0, 1, or 2. I could really use the higher priorities (like processhacker can set), so how did someone modify it to accept the -5 or -4 mentioned above? I examined the source, but see uint (unsigned, right?) all over the place.

    Also, TimG, did you try using the process name without the '.exe'?

     
  • Col

    Col - 2019-05-01

    i tried -5 on a thread then the app wouldn't close not even with processhacker terminator plugin.

    if i set the same thread using processhacker then the app closes fine which is using the value 3 not -5.

    i'm pretty sure processhacker gets it done by elevating privileges on startup or something like that.

    so use -4, -5 at ur own risk. still a nice find tho :)

    Edit: knew i spoke too soon lol, seems the closing problem only happens when the app is launched from visual studio which also hangs for a while when closing the app or using the stop button. i wonder if other apps can take a severe hit tho? like disk intensive ones.

     

    Last edit: Col 2019-05-01

Log in to post a comment.