Monday, May 15, 2006

Boosting priority of Visual Studio .NET compilation

Long, long, long time ago a trick was published on CodeGuru, letting you to decrease priority of the compilation process (cl.exe) spawned by VC++ environment.

Build process is a relatively resources-consuming task and those days - running a big build was almost freezing your computer for hours, hardly letting you to browse an internet site in the background.
So, the trick was to look for the combination of CREATE_NEW_PROCESS_GROUP and NORMAL_PRIORITY_CLASS flags (together giving a value of 68 00 02) in the vcspawn.exe process and then change 00 02 into 40 02, which is the value of IDLE_PRIORITY_CLASS (actually it's 0x00000040 - so you getting 40 00 after you swap its bytes to fit physical representation in memory).

Now, today I encountered an absolutely opposite problem: we have a dedicated "daily build" machine, which only purpose is to run daily build, unit tests and pack daily build installation. I noted that a big span of time required for this whole process to complete is spent by compilation (cl.exe).
So I wanted to increase its default priority and this way to speed up whole build process.
Well, the old trick still works - all you need is to look for 68 00 02 in vcspawn.exe and change it to 68 80 02 (HIGH_PRIORITY_CLASS).