Beware of .NET 4.6 Workstation GC

August 8, 2015

no comments

TL;DR: Changes in the .NET 4.6 Workstation GC has made it much slower for us. We had to make sure our tests are using the Server GC mode.

VS 2015 came out and we happily upgraded. Everything worked great, except for one thing: our integration tests started to run slowly. Like 10 times slower. The thing is, the same code, when not running under the NUnit process, worked just fine. Something was afoot.

After much investigation and profiling, we discovered the root cause: GC. Our integration tests run our entire system start-up process, which allocates a few gigs of caches. Ever since installing VS 2015, and .NET 4.6 with it, allocating all this RAM took a much longer time, due to GC. But, and this is a really important but, this doesn’t happen if you use Server GC mode, which we thought we did. Our unit tests were running under the Resharper tests runner process, which didn’t respect the <runtime> config section in our IntegrationTests app.config. That means that we were actually using workstation GC in our integration tests since forever, but didn’t notice it until .NET 4.6 came and made things much slower.

The solution to all this was forcing the Resharper test runner (or whatever process is running your tests) to use the server GC mode. I did this by opening this folder: C:\Users\YouUserName\AppData\Local\JetBrains\Installations\ReSharperPlatformVs14, and editing the file JetBrains.ReSharper.TaskRunner.CLR45.x64.exe.config. Here I just added <gcServer enabled=”true” /> under the runtime section. Now, you can either force Resharper to always use CLR 4.5 & x64 in the options (which is what we did), or do the same for all other JetBrains.ReSharper.TaskRunner config files.

This is not an ideal solution. We would have to remember to keep editing these files every time we reinstall ReSharper. Also, I can’t really explain what has made things so much worse in the new workstation GC. I guess time will tell.

Add comment
facebook linkedin twitter email

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*