In the latest releases of the C++ Extension in Visual Studio Code, we have focused on performance improvements and stability. A fast, responsive, and reliable development environment is essential for maintaining productivity, especially in large and complex C++ projects. These updates include many incremental optimizations that collectively speed up the time from opening a C++ project to writing code with the full suite of C++ features available at your fingertips. Experience these new features for yourself by updating to the newest version of the C++ Extension.
Faster Project Startup and Time to Colorization
Many different optimizations have been made in the C++ extension to provide better initialization performance on project startup and when configuring IntelliSense. If you’re working on a large or complex project on a MacOS or Linux machine, you’ll notice a significant improvement.
Through our testing, we found an average 3.4x speedup on Linux and 3.6x speedup on MacOS . Testing was done with a basic machine using VS Code 1.97.1 and the PyTorch source code.
When opening a source file, semantic highlighting (colorization) is also now much faster. This change is due to the C++ Extension now caching configuration information rather than relying on real-time processing, resulting in much faster configuration access.
Based on our testing, we found an average 4x speedup in the time to file colorization, 4.8x for Linux, and 3.3x for MacOS. This testing was done using VS Code 1.97.1 on a basic machine and colorizing a representative file in the PyTorch source code.
Optimizing IntelliSense Configuration
IntelliSense is the core of the C++ Extension, building your coding experience into a dynamic process with real-time analysis and insights. This ranges from autocompletion to file navigation like “Go to Definition”. But in order for IntelliSense to be able to provide this information, it must understand your project’s configuration. Configuration details, such as compiler settings and include paths, are parsed on project startup.
With this release, we optimized the IntelliSense configuration process. The biggest change is that compiler configurations are now cached. A quick retrieval via the database is much faster than identifying and querying the correct compiler every time a project is opened. This leads to faster population of IntelliSense features as seen in the previous section for time to colorization.
We have optimized further by parallelizing different processes during file discovery. For example, determining the relationship between source and header files and lookups of different #include files now happen in parallel, providing faster results. Additionally, an updated path canonicalization process for MacOS and Linux uses better path resolutions to standardize file paths. This eliminates redundancies like relative components, reduces file system access, and improves performance across the different operating systems.
Beyond configuring with a compiler, we also optimized the process of using alternate methods for configuration, such as custom configurations. It is now faster to reconfigure a custom configuration provider, and the selected C++ configuration can also now be easily switched within the extension. Switching a configuration is available via a new parameter thanks to the work of @adrianstephens.
We have also expanded support for configuring your project via a compile_commands.json file. A project can now support multiple compile_command.json file, thanks to the contributions of @yiftahw. This makes it easier for build systems that run CMake separately in different repositories to be able to specify which CMake version to use via multiple separate compile_commands files. Additionally, there is now faster processing of large and complex compile_commands.json files, especially for files with thousands of entries. Combined with the new configuration caching, this creates a better startup experience.
Other Enhancements
Beyond startup time and IntelliSense improvements, we’ve introduced additional enhancements to improve performance and usability:
- An improved implementation of file buffers, reducing memory usage while using the extension
- Additional settings have been added to the C/C++: Log Diagnostics output for more details on the environment setup and configuration, including modified C_Cpp settings, additionally tracked settings, and the database path used.
To learn more about these changes, please reference the changelog.
What do you think?
Download the C/C++ extension for Visual Studio Code today, give it a try, and let us know what you think.
If you have any questions around this release, feel free to start a discussion in our GitHub repository. Otherwise, if you run into any issues, please report them in the issues section. We can be reached via the comments below, per email at visualcpp@microsoft.com, or through our team on X/Twitter at @VisualC.
The post VS Code C++ Extension Updates: 4x Faster Colorization & 3.5x Faster Project Startup appeared first on C++ Team Blog.