Thursday, April 7, 2016

Maintain System Responsiveness when Running a Parallel Visual Studio Build

The recent addition of encryption to laptops with spinning platter drives has proven painful for many developers on my project. A big complaint has been the lack of responsiveness of the system while doing a parallel build. Tasks that should be nearly instantaneous take several second to nearly a minute. Since some of these tasks such as switching between files or applications might need to occur many times in a minute to complete a larger activity; these delays stack and take away the opportunity to be productive doing other things like preparing slides or creating documentation. This article provides a work around to solve this problem until SSDs are available to all developers who need them. Note that improving your system's responsiveness while building will increase the time that it takes to build.

This method works by lowering the I/O priority of the processes doing the build. This is not possible using the built in Windows Task Manager. Instead use either Process Explorer, which is available for free from Microsoft, or Process Lasso, which has a free evaluation but requires a paid license for commercial use. Process Lasso also has a neat feature that I'll go into more detail about later that automatically changes the priority of the processes any time a build start.

Using Process Explorer you can change the priority of all MSBuild.exe1 processes to Background (Low I/O).

Using Process Lasso you can change the I/O priority of all MSBuild.exe1 processes to Very Low. You can do this "Current" which will only affect the currently running processes, or do it always which will modify any MSBuild.exe process currently running or created in the future while Process Lasso is running. It took some work to get this to work, I had make sure I had it configured to control all users processes, then make sure I closed and reopened Process Lasso after installing. If you want this feature to work, play with it and make sure it is.

A few things to note: If you work on some unrelated code and want to build a small project while a big parallel build is running, it will take a really, really long time for that small project to build. Get around this by cancelling your large build and letting your small project build then resuming your large build. Remember, the solution described here is just a work around, if you want to do things in a reasonable way, you're going to need an SSD. Also, if your system is unresponsive while building, you'll probably notice other times that it is unresponsive during heavy I/O as well. If you your system to always be snappy, you're going to need an SSD. And, once again, if you are using this method to do other things it will make your build take longer. If you want to be able to work while building and still have reasonable build times, you're probably going to need an SSD.

One other thing I noticed is that Intellisense can take a long time to run and its heavy I/O exacerbates the problem. I disabled Intellisense until I get an SSD which will make Intellisense usable again.


1. Its necessary to do this to the MSBuild.exe processes because they are always started at normal priority, despite their priority of their parent process

No comments:

Post a Comment