Running DevStudio 6.0 builds in low priority
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.

Comments
Process Lasso (NOT just another task manager)
Posted by goofium on 02/26/2010 10:44amProcess 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
ReplySolution for MSVC 2005
Posted by Fragmachine on 06/10/2008 07:20pmThis 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).
-
ReplyAddress to do this
Posted by Isak Swahn on 05/27/2009 12:05pmFor 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.
ReplyThanks
Posted by Legacy on 11/29/2003 12:00amOriginally posted by: Hamilton Gross
That was exactly what I was looking for...remarkable!
H
ReplyHow did you know that the function parameters occur at this address
Posted by Legacy on 05/22/2003 12:00amOriginally posted by: matthew
Im interested to know how you new this and if so could you please tell me.
ReplyCan we increase the base priority of VSspawnexe to "high"
Posted by Legacy on 12/31/2002 12:00amOriginally posted by: santosh thankachan
-
-
ReplyJust curious, but...
Posted by Isak Swahn on 05/27/2009 12: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?
ReplyEasy Enough
Posted by Synetech on 01/19/2009 03:15pmOf course this is possible, just use 0x80 instead of 0x40. You can find the relevant definitions in WinBase.h.
ReplyWindows CE - Embedded Visual Tools v3
Posted by Legacy on 07/23/2002 12:00amOriginally 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.
ReplyVC7 vcspawn.exe is different
Posted by Legacy on 07/11/2002 12:00amOriginally posted by: Mark Webb
-
-
-
ReplyTwo Instances
Posted by Synetech on 01/19/2009 03:40pmThere 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.
ReplyFor beyond-NT, there's below normal which is better than idle
Posted by 40th Floor on 05/27/2005 12:37pmSo, 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 Thread: http://groups-beta.google.com/group/microsoft.public.vc.ide_general/browse_frm/thread/3e5f956875f44ef8/db7258b19f5faba6?tvc=1&q=Lower+compiler+and+linker+priority%3F+group:microsoft.public.vc.ide_general&hl=enReplyvs71 vcspawn.exe is different
Posted by 40th Floor on 07/05/2004 12:55amYH [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 someReplySuperb
Posted by Legacy on 12/05/2001 12:00amOriginally posted by: Petri Simolin
Replyinternet protocol
Posted by Legacy on 06/13/2001 12:00amOriginally posted by: abderrahim gamh
it's a great work which you have made , i hope to see more
Replydeveloppements in this field, as i hope to have the possibility to have some cours about visual basic studio 0.6
professionel.
thank you for giving us the occasion of giving our comments.
Error spawning 'vcspawn.exe'.
Posted by Legacy on 04/07/2001 12:00amOriginally 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?
ReplyLoading, Please Wait ...