Virtual Developer Workshop: Containerized Development with Docker

During large project builds, it is usually useful to do other stuff with your computer (like checking out the latest cool stuff on CodeGuru :) ), but I find that the computer becomes very sluggish, until I change the priority of the vcspawn.exe and cl.exe to low using the NT task manager. After doing so, the computer becomes quite responsive until the next build...

Since Microsoft didn't provide an option to automatically run the compiler/linker in low priority, I've figured a way that easily does this. What I have done is located in the vcspawn.exe executable, the call to CreateProcessA(). One of the parameters (dwCreationFlags) includes the priority at which you wish to run the created process. Vcspawn.exe normally runs everything with the dwCreationFlags set to 0x00000200, which decoded means use only the CREATE_NEW_PROCESS_GROUP flag. What I wish to include in the dwCreationFlags parameter is the flag, IDLE_PRIORITY_CLASS which is 0x00000040, so my replacement dwCreationFlags is 0x00000240 - a one byte difference. After making the simple one byte edit, all my builds are performed in low priority mode. Now you may think that by running at low priority, all your builds will take longer to complete, but you will be surprise at the little difference in actual build times, unless you were doing some other heavy duty task.

To make the one byte edit, first backup \Program Files\Microsoft Visual Studio\MSDev98\Bin\vcspawn.exe and then from inside DevStudio, open in BINARY mode, vcspawn.exe. Bring up the Go To dialog by typing, control-g, and key in the address 0x27ec and close the Go To dialog. The byte should be 00 with the previous byte being 68 and the following byte being 02. If they are not, then you are running a different version of vcspawn.exe and you shouldn't attempt the change. If they are, then you can just type in the replacement byte of 40. The new byte sequence starting at 0x27eb should now read 68 40 02. Save and close the file. Now all further builds will be performed in low priority.

Note for VC++ 5.0 vcspawn.exe, you can do the same type of change at address 0x0e49, changing the byte from 00 to 40.


  • Process Lasso (NOT just another task manager)

    Posted by goofium on 02/26/2010 06:44pm

    Process Lasso will allow you to do this by setting a default priority class of 'Below Normal' or 'Idle' for cl.exe. After this, EVERY TIME cl.exe is launched its priority class will be 'Below Normal'. The same can be done for other external build tools of Visual Studio. However, the best thing about Process Lasso is that you don't have to even configure this default priority to have it help system responsiveness during builds. In fact, it can even do this same thing automatically without you having to configure it! This is its ProBalance function. When a background process executable exceeds a CPU usage threshold, it will be automatically and temporarily lowered in priority to prevent system responsiveness problems. The algorithm has been carefully tweaked over years to ensure it functions well in all environments. Since Process Lasso is written in native C++ with a stand-alone core engine that does the real work, its very light on its feet too.. It works wonders, it really does. Again, Process Lasso is NOT a simple task manager, it is utility to help automate and persist process priority and affinity adjustments, amongst another thing

  • Solution for MSVC 2005

    Posted by Fragmachine on 06/11/2008 02:20am

    This awesome hack still works in the 2005 version by hex editing the VcBuildHelper.exe in the 'Microsoft Visual Studio 8\VC\vcpackages' folder. Even with today's multi-core machines it's a very relevant trick since parallel builds in Visual Studio very easily eats up all CPU resources. On a developer machine I would recommend using priority BelowNormal (68 00 42) so it's still above background resources such as a screen saver etc (in my case BOINC).

    • Address to do this

      Posted by Isak Swahn on 05/27/2009 07:05pm

      For anyone else who's searching, the 68 00 02 sequence to be changed appears two places in the file: at 0x17e8 and 0x4871. I changed this to 68 00 42 both places, and it seems to work fine.

  • Thanks

    Posted by Legacy on 11/29/2003 08:00am

    Originally posted by: Hamilton Gross

    That was exactly what I was looking for...remarkable!


  • How did you know that the function parameters occur at this address

    Posted by Legacy on 05/22/2003 07:00am

    Originally posted by: matthew

    Im interested to know how you new this and if so could you please tell me.

  • Can we increase the base priority of VSspawnexe to "high"

    Posted by Legacy on 12/31/2002 08:00am

    Originally posted by: santosh thankachan

    Please let me know if we can change the base priority of the Vcspawn.exe to high as we change it to low.

    Some times we may need to compile and link the libraries at the top most priority , my requirements actually ;-)

    Santosh Thankachan

    • Just curious, but...

      Posted by Isak Swahn on 05/27/2009 07:15pm

      ...why on earth would someone run a batch job at high priority? To make the CPU run it faster? It won't. Or just to make interactive jobs run slower?

    • Easy Enough

      Posted by Synetech on 01/19/2009 11:15pm

      Of course this is possible, just use 0x80 instead of 0x40. You can find the relevant definitions in WinBase.h.

  • Windows CE - Embedded Visual Tools v3

    Posted by Legacy on 07/23/2002 07:00am

    Originally posted by: Ian

    This same trick can be used in Embedded Visual Tools (v3 at least).

    vcspawn.exe is located in "%EmbeddedToolsInstallDirectory%\Common\EVC\Bin", where the default for %EmbeddedToolsInstallDirectory% is usually "c:\Program Files\Embedded Visual Tools"

    Again backup, then open vcspawn.exe in a suitable hex editor, and move to offset 0x1aba, where you will find a 00 byte. (Like the other environments, the bytes either side are 68 [00] 20 00 00)

    Change this byte to 40, save and close.

  • VC7 vcspawn.exe is different

    Posted by Legacy on 07/11/2002 07:00am

    Originally posted by: Mark Webb

    After moving to VC7, I tried the same tip and VcSpawn.exe seems to have been modified and rebuilt.

    However, I think I have isolated the byte to change in the new version. Making the following change has not caused any disruption on my system, and I am getting the same benefits as the VC6 modification in this article.

    - First open vcspawn.exe in a binary editor (make a backup first)
    - Then goto offset 0x0000114b

    The memory should appear like this:
    3C 00 00 00 [00] 02 00 00

    - Modify that byte to be 40, e.g.
    3C 00 00 00 [40] 02 00 00

    • Two Instances

      Posted by Synetech on 01/19/2009 11:40pm

      There are actually two instances of the CreateProcess call in vcspawn.exe (at least in VS 2003 SP1). You should probably patch both, or just set the IDE priority instead.

    • For beyond-NT, there's below normal which is better than idle

      Posted by 40th Floor on 05/27/2005 07:37pm

      So, instead of 
      vcspawn_org.exe                         vcspawn.exe 
       401D3F: 68 00 02 00 00 push  200h      401D3F: 68 40 02 00 00 push  240h 
       401D44: 6A 01          push    1       401D44: 6A 01          push  1 
      E:\vs2003\Common7\Tools>fc vcspawn_org.exe vcspawn.exe 
       Comparing files vcspawn_org.exe and VCSPAWN.EXE 
       00001140: 00 40 
      it's better to be 
              vcspawn_org.exe                         vcspawn.exe 
       401D3F: 68 00 02 00 00 push  200h      401D3F: 68 00 42 00 00 push  4200h 
       401D44: 6A 01          push    1       401D44: 6A 01          push  1 
      E:\vs2003\Common7\Tools>fc vcspawn_org.exe vcspawn.exe 
       Comparing files vcspawn_org.exe and VCSPAWN.EXE 
       00001141: 42 02 
      Go catch.  Monkey-see-monkey-do is a good excuse for the first go. 
      Did you really see 50/50 between the idle process and the compile 
      in practice, or is it based in theory? 
      =?Utf-8? [Thu, 17 Mar 2005 13:17:02 -0800]: 
       > This makes the compiler and linker run at BELOW_NORMAL, which is perfect for 
       >this type of task 

    • vs71 vcspawn.exe is different

      Posted by 40th Floor on 07/05/2004 07:55am

      YH [Mon, 05 Jul 2004 02:03:36 GMT]:
       >However, you may run it at your own risk since it is somewhat hacky
      That depends on how you define hacky.
       >as you said and there is no such setting in VS.NET yet.
      I've been doing it for a while.
      2003-03-19  05:15               17,408 vcspawn_org.exe
      2004-01-23  19:51               17,408 vcspawn.exe
              vcspawn_org.exe                         vcspawn.exe
       401D3F: 68 00 02 00 00 push  200h      401D3F: 68 40 02 00 00 push  240h
       401D44: 6A 01          push    1       401D44: 6A 01          push  1
      E:\vs2003\Common7\Tools>fc vcspawn_org.exe vcspawn.exe
       Comparing files vcspawn_org.exe and VCSPAWN.EXE
       00001140: 00 40
       40th Floor - Software  @  http://40th.com/
       iPlay : the ultimate audio player for iPAQs
       mp3, ogg, mp4, m4a, aac, wav, and then some

  • Superb

    Posted by Legacy on 12/05/2001 08:00am

    Originally posted by: Petri Simolin

    Works like a dream. I used to manually decrease the priority from the task manager.

  • internet protocol

    Posted by Legacy on 06/13/2001 07:00am

    Originally posted by: abderrahim gamh

    it's a great work which you have made , i hope to see more
    developpements in this field, as i hope to have the possibility to have some cours about visual basic studio 0.6
    thank you for giving us the occasion of giving our comments.

  • Error spawning 'vcspawn.exe'.

    Posted by Legacy on 04/07/2001 07:00am

    Originally posted by: erkin karincaoglu

    I can not build a simple mfc project if I start msdev.exe from start menu.But if I just wrote "start msdev.exe" from command prompt there is no problem,I can build any project.Anyone can explain this?

  • Loading, Please Wait ...

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date