Speed up Visual Studio load times with Microsoft Dev Box
Published Aug 10 2023 10:00 AM 5,391 Views
Microsoft

Overview

This year at Microsoft Build we demonstrated Visual Studio pre-caching for Microsoft Dev Box, one of the many integrations that make using Visual Studio on Microsoft Dev Box a great experience. Now with Visual Studio 17.7, you can try out pre-caching for yourself on Microsoft Dev Box.

 

Visual Studio utilizes many caches to increase the performance of key features like Find in Files and IntelliSense. When opening a solution for the first time these caches must be generated by indexing and processing the codebase. Working with large solutions can add a significant amount of time to startup while these caches are created. Once the caches are created Visual Studio can quickly use these features.

 

With Microsoft Dev Box we create ready-to-code development desktops in the cloud. This means you can create a custom Dev Box Image with all the tools, source code, and dependencies your development project needs. With this project specific image, Dev Box users can get developing right away with everything their project needs already prepared for them.

 

Visual Studio’s /PopulateSolutionCache along with the /localCache switch now allows Dev Box users to generate these Visual Studio caches and include them as part of their Dev Box Image. As a result, Visual Studio is able to load your solution and enable Visual Studio’s feature faster on Dev Box.

 

Using Chromium as an example large repository, we saw the initial solution load decrease by 75% using pre-generated caches for Dev Box. for Dev Box. We saw similar results testing with the Unreal Engine repository, reducing the total load time down from 117 seconds to 19 seconds. When using the pre-created cache on Dev Box, C++ IntelliSense is available right away without waiting. The cache only needs to be created once and then can be shared by all developers using the shared Dev Box image. This saves time for everyone on your team since they no longer need to generate the same cache data locally.

 

gregdenton_0-1691635627645.png

 

While these improvements are quite noticeable, startup is not the only area caches can help. If you’ve worked on a large Git repository, you might have noticed performance issues when viewing your Git repository, visualizing the commit history or doing other operations that are related to the number of commits in your repository.

 

Last year, we announced support for the commit graph feature. Based on our observations, this feature can dramatically improve the Git performance on large repositories.

 

We saw a 75% performance gain in Visual Studio using a repo with 33,000 commits and a 98% performance gain when loading git history for a repo with 1 million commits.

 

Thanks to Microsoft Dev Box, you can now enable these improvements automatically and side-by-side with the other cache improvements.

 

Generating Caches in Dev Box Images

We’ve enabled the generation of caches through a command line flag added to the Visual Studio devenv.exe executable. This allows you to generate Visual Studio caches as part of an automated pipeline for generating your custom Dev Box Images.

 

The requirements for generating the caches are:

  • You are using Microsoft Dev Box for your development workstations.
  • Your Dev Box image includes Visual Studio 17.7 Preview 3 or higher.
  • You have created a custom Dev Box Image that includes the source code for your project.

 

In order to generate the Visual Studio caches, you will need to execute the following command as part of your Dev Box Image build process:

 

devenv mysln.sln /PopulateSolutionCache /LocalCache [/Build [SolnConfigName [/Project ProjName [/ProjectConfig ProjConfigName]] [/Out OutputFilename]]]

 

[Build options]

 

This command will open mysln.sln, execute a build, and generate the caches for the specified solution. You can combine the generation of caches and running a build by including the optional /Build switch which will ensure all build cache data is also created. Once you have created a dev box image that includes your project source and caches, it must be associated with a dev box definition.

 

Users who deploy a dev box from a dev box pool using this definition will be able to open the solution and Visual Studio will read the already generated caches, skipping the cache generation altogether.

 

Enabling Git Commit-Graph optimizations

Like the cache generation, you can also enable Commit-Graph optimizations as part of an automated pipeline that generates custom Dev Box Images.

The requirements for enabling Commit-Graph are:

  • You are using Microsoft Dev Box for your development workstations.
  • Your Dev Box image includes Visual Studio 17.7 Preview 3 or higher.
  • You have created a custom Dev Box Image that includes the source code for your project.

 

To enable this optimization, you’ll need to execute the following git.exe commands from your Git repository’s location as part of your image build process:

  • git config --local core.commitGraph true: this command enables the Git repository to use the commit-graph file, if the file is present
  • git commit-graph write --reachable: this command updates the Git repository’s commit-graph file to contain all reachable commits

 

Caches with Dev Box Customizations

Microsoft Dev Box recently announced the Private Preview of new customization capabilities. With Microsoft Dev Box customizations, users can utilize a config-as-code devbox.yaml file to further customize their Dev Box environment. This allows developers to have more control to self-manage their workstation environment and define what is installed for their projects.

For any users who want to generate Visual Studio caches as part of Dev Box customizations, we’ll be working with the Customization team to also include the same ability to generate your Visual Studio caches as part of Dev Box Customizations. Simply run the same command as above within your devbox.yaml to generate your caches in advance.

 

Get Started with Dev Box Today

Microsoft Dev Box is now Generally Available and we encourage you to try it out yourself to see how it can transform your developer experience and now with pre-caching for Visual Studio, you can get started developing faster than ever before. Download and install Visual Studio 17.7 to get started.

 

We’d love to hear your feedback, input and suggestions on Visual Studio pre-caching and Dev Box via the Developer Community.

 

 

 

Co-Authors
Version history
Last update:
‎Aug 09 2023 08:32 PM
Updated by: