{"id":250827,"date":"2024-10-01T07:32:23","date_gmt":"2024-10-01T14:32:23","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/visualstudio\/?p=250827"},"modified":"2024-10-07T14:58:33","modified_gmt":"2024-10-07T21:58:33","slug":"visual-studio-2022-recent-performance-enhancements","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/visualstudio\/visual-studio-2022-recent-performance-enhancements\/","title":{"rendered":"Visual Studio 2022 &#8211; Recent performance enhancements\u00a0"},"content":{"rendered":"<p>Visual Studio 2022 continues to be faster with each version. In this blog post we will highlight a couple of the more significant enhancements you\u2019ll experience in 17.11, such as a more efficient C# language service, faster conditional breakpoints and symbol searches in C++.<\/p>\n<h2>Reduced CPU usage by C# language service<\/h2>\n<h2>Code Indexing<\/h2>\n<p>In 17.10 we revamped the code indexing system in the C# language service (Roslyn).\u00a0It used to be both aggressive and highly intermittent.\u00a0 This would lead to high spikes of CPU usage, taking resources away from the operations users were performing, especially during times like solution load.\u00a0 After opening a solution, users who wanted to wait for VS to settle would have to wait up to minutes watching a progress bar titled \u201cRunning low priority background processes\u201d.<\/p>\n<p>Now, we no longer preemptively run all the indexers.\u00a0 Instead, individual ones are run on demand.\u00a0 In 17.11, these indexers were further streamlined, and made much more incremental, allowing them to consume far less resources when absorbing any change into the index.\u00a0In addition, there were memory allocation optimizations throughout the editor and managed language services. The net effect of this is a more responsive VS that is ready to go at a much sooner time, with much lower CPU consumption.<\/p>\n<h2>Source Generators<\/h2>\n<p>As part of our continued work to break VS into isolated, high performance, services, Roslyn&#8217;s Source Generator execution host was moved out of the main VS process to a high-performance .NET 8 host.\u00a0 This helps make VS more resilient to bugs in source generators and allows them to execute much more efficiently.\u00a0 As part of this work, we also changed the execution model for source generators to no longer run automatically, due to the heavy impact that some generators can still have on the system.\u00a0 Instead, by default, generators will now run when a document is saved, or a project is built, greatly cutting down on the impact of all generators (especially very expensive ones).\u00a0 This behavior can be controlled here:<\/p>\n<p>Tools &gt; Options &gt; Text Editor &gt; C# &gt; Advanced &gt; Source Generators<\/p>\n<p><img decoding=\"async\" width=\"1051\" height=\"165\" class=\"wp-image-250828\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/09\/a-screenshot-of-a-computer-description-automatica-5.png\" alt=\"A screenshot of a computer Description automatically generated\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/09\/a-screenshot-of-a-computer-description-automatica-5.png 1051w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/09\/a-screenshot-of-a-computer-description-automatica-5-300x47.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/09\/a-screenshot-of-a-computer-description-automatica-5-1024x161.png 1024w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/09\/a-screenshot-of-a-computer-description-automatica-5-768x121.png 768w\" sizes=\"(max-width: 1051px) 100vw, 1051px\" \/><\/p>\n<p>With the above changes in place, our data shows improved metrics in 17.11. CPU usage is down by 16% percent or more in sessions that had heaviest CPU usage. The C# completion list now appears sooner; looking at the slowest sessions the number of times the list takes longer than 0.5 seconds to appear has been cut by about 40%.<\/p>\n<h2>Improved conditional breakpoint performance<\/h2>\n<p>In 17.11 we made several changes to improve the performance of conditional breakpoints in C++. The improvements were primarily in two categories:<\/p>\n<ul>\n<li>Avoiding expensive Windows debugging API calls. Windows calls to get and set information about the debugged process can be expensive, so the data was cached to reduce the number of calls to these APIs. Additionally, some of the information was already available through other sources, allowing some calls to be eliminated entirely.<\/li>\n<li>Reducing data fetched from the debugged process. When a breakpoint is hit, the debugger must fetch a lot of information about the state of the debugged process. This is needed to populate things such as the locals tool window, the Diagnostics Tools window etc. However, to evaluate whether a conditional breakpoint\u2019s conditions have been met, we need only a subset of that information. Now we fetch only the necessary pieces of information.<\/li>\n<\/ul>\n<p>With these optimizations in place, we measured up to ~67% reduction in debugger overhead in a test application compared to 17.10.<\/p>\n<h2>Optimized Symbol Search for C++ language service<\/h2>\n<p>In 17.11 we reimplemented the text indexing system for C++ symbols.\u00a0Before this change, C++ language service processed the symbol text directly to answer <a href=\"https:\/\/learn.microsoft.com\/en-us\/visualstudio\/ide\/visual-studio-search?view=vs-2022#search-in-visual-studio-2022-version-176-or-later\">All-in-one-Search<\/a> (AIOS) queries.\u00a0We would load all the text into memory and traverse it to find matching candidates.\u00a0This approach was relatively fast, but not optimal; not to mention having to keep the text cached in memory.\u00a0In 17.11 we started using SQLite\u2019s <a href=\"https:\/\/sqlite.org\/fts5.html\">FTS5<\/a> search extension.\u00a0The index is computed when the solution is parsed after it is opened, and then the language service can perform Symbol Search without any additional loading of text into memory.\u00a0All the results are available faster and with less memory usage: we\u2019ve seen the slower AIOS symbol searches up to 65% faster in 17.11. We hope you\u2019re experiencing this improvement in your larger codebases.<\/p>\n<h2>Share your feedback and stay connected with Visual Studio!<\/h2>\n<p>We appreciate the time you\u2019ve spent reporting issues\/suggestions and hope you continue to give us feedback when using Visual Studio on what you like and what we can improve. Your feedback is critical to help us make Visual Studio the best tool it can be! You can share feedback with us via\u202f<a href=\"https:\/\/developercommunity.visualstudio.com\/home\" target=\"_blank\" rel=\"noopener\">Developer Community<\/a>: report any bugs or issues via\u202f<a href=\"https:\/\/learn.microsoft.com\/visualstudio\/ide\/how-to-report-a-problem-with-visual-studio?view=vs-2022\" target=\"_blank\" rel=\"noopener\">report a problem<\/a>\u202fand\u202f<a href=\"https:\/\/developercommunity.microsoft.com\/VisualStudio\/suggest\" target=\"_blank\" rel=\"noopener\">share your suggestions<\/a>\u202ffor new features or improvements to existing ones.<\/p>\n<p>Stay connected with the Visual Studio team by following us on <a href=\"https:\/\/www.youtube.com\/@visualstudio\" target=\"_blank\" rel=\"noopener\">YouTube<\/a>, <a href=\"https:\/\/twitter.com\/VisualStudio\" target=\"_blank\" rel=\"noopener\">Twitter<\/a>, <a href=\"https:\/\/www.linkedin.com\/showcase\/microsoft-visual-studio\/\" target=\"_blank\" rel=\"noopener\">LinkedIn<\/a>, <a href=\"https:\/\/www.twitch.tv\/visualstudio\" target=\"_blank\" rel=\"noopener\">Twitch<\/a> and on <a href=\"https:\/\/learn.microsoft.com\/en-us\/visualstudio\/?view=vs-2022\" target=\"_blank\" rel=\"noopener\">Microsoft Learn<\/a>.<\/p>\n<p>On behalf of the entire Visual Studio team, thanks for reading and Happy Coding!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Visual Studio 2022 continues to be faster with each version. In this blog post we will highlight a couple of the more significant enhancements you\u2019ll experience in 17.11, such as a more efficient C# language service, faster conditional breakpoints and symbol searches in C++. Reduced CPU usage by C# language service Code Indexing In 17.10 [&hellip;]<\/p>\n","protected":false},"author":642,"featured_media":250912,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[6868,155],"tags":[1423,5608,1404],"class_list":["post-250827","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-performance","category-visual-studio","tag-breakpoints","tag-roslyn","tag-search"],"acf":[],"blog_post_summary":"<p>Visual Studio 2022 continues to be faster with each version. In this blog post we will highlight a couple of the more significant enhancements you\u2019ll experience in 17.11, such as a more efficient C# language service, faster conditional breakpoints and symbol searches in C++. Reduced CPU usage by C# language service Code Indexing In 17.10 [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/250827","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/users\/642"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/comments?post=250827"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/250827\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media\/250912"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media?parent=250827"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/categories?post=250827"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/tags?post=250827"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}