Improving Visual Studio 2010 performance
About two months ago, we upgraded our projects to Visual Studio 2010. Since then the developers started to complain about the performance of the IDE. It seems to have degraded in comparison to VS2008. From build times that doubled to stalling in the editor when you code.
Other teams in our department started to complain as well.
We started to investigate the problem. We looked into three key points:
Solution maintenance
This is a key issue. From previous experience we found that solutions that are not maintained properly are doomed to cause trouble.
This relates mostly to build time, but it can also affect the IDE because, as you know, visual studio and add-ins like resharper are constantly compiling your new code in the background.
I started by changing the build output verbosity:
My conclusions are:
Minimize the number of projects in the solution
I found that each project builds in about 2-4 seconds (Silverlight project takes about 9 seconds), but the transition between the projects takes a lot of time. When you many projects, this has a drastic affect on the build time. So try to merge projects.
For example:
Use folders and namespaces instead of splitting into projects where you can.
Merge all the tests (unit, integration) into a single project (per type). It also make it easy to manage the tests in the CI server.
Remove redundant references from projects
I found that the resolving references stage is quite long and I have too many projects with unneeded references. I used resharper in order to find dependent code in a project and deleted the references which didn’t have dependent code.
Do not build setup/deploy projects in debug mode
Setup projects and web deployment projects takes a long time to build. Make sure that in debug build configuration (Build –> Build Configurations) setup and web deployment projects are not marked for build.
Visual Studio
Patches
Since the release of Visual Studio 2010, Microsoft released a couple of patches to fix known issues:
Scrolling Context Menu
Find Replace Dialog growing
Cut/Copy “Insufficient memory”
I recommend to all of you to subscribe to the Visual Studio blog or to Scott Guthrie’s blog for the latest’s updates to visual studio.
Windows Automation UI
Another important issue is Window Automation UI. Microsoft recommend to install it if you are running on windows xp. You can also notice the visual studio icon that appears on your system tray, which shows this recommendation.
In short, when installed it is suppose to make visual studio to run faster (rendering wise).
Diagnostics
Our contact in Microsoft support, recommended us to install the Visual Studio Diagnostics Tool. This tool is used for collecting trace information on visual studio performance. These logs can be analyzed independently or can be sent to Microsoft Support. I haven't had a chance to install it yet. I will update on this soon.
Add-ins and extensions
As you probably know, Visual Studio 2010 with the Visual Studio Gallery allows you to install a lot of add ins and extensions. In lot of cases one or more of these can have drastic effect on performance. It is recommended to run Visual Studio in safe mode with the safe mode switch:
devenv /safemode
In safe mode, all the add-ins and extensions are disabled. If you see any performance improvement, try to activate the add ins and extensions one by one and diagnose which one causes the performance impact.
Hardware
Defragmentation
Fragmented disk cause slower build times (which as mentioned can also affect IDE general performance). In my team, we found that the image which is used to install windows on the dev machines was seriously fragmented. After defrag build time decreased by half!!
It is a known windows performance issue, so every once in a while you need remember to do a scan disk and defrag your drives (You can add a schedule task or use Windows's defrag to schedule these when you want)
Maintain your machine
Cleanup your machine every once in a while. I use CCleaner to clean up the drives and registry and it works great.
DirectX
There are some articles on the web which indicates that visual studio doesn’t run well on machines without a graphic card that supports DirectX 9. This is due to the new UI which is built on WPF. Our dev machines doesn’t have graphic card slots so I couldn’t check it. If you have a chance, I recommend you try, and comment on your results. In my home computer which have a pretty massive graphic card Visual Studio works well, but I don’t have solutions with 30+ projects…
Hardware acceleration
Visual Studio uses hardware accelerations (as mentioned). You can try to disable it, for better performance:
Our machines doesn’t have graphic acceleration, so we tried this and performance got better, most of the times.
If you have any more tips and tricks on how to improve and diagnose performance issues in VS, please share it with us.
Happy hunting