November 21st, 2022

Visual Studio 2022 Performance Enhancements 17.4

Nayana Srikanth
Senior Product Manager

Every new Visual Studio release includes new performance improvements that make the product faster and more responsive. 17.4 has some significant improvements across common scenarios likeĀ  Find in Files, Branch switching, configuration changes, unit testing, C++ indexing and file saving. We use product telemetry from our GA releases to set baselines, run experiments in previews to test different solutions, measure changes in controlled lab environments for repeatable results, and dogfood builds daily to test our changes. While your mileage may vary, we believe there is something here for everyone. Download Visual Studio 2022 to check out some of the improvements below.Ā 


Find and Replace in FilesĀ 

Replace in Files on the entire solution is now 3-4 times faster! You’ll see a significant improvement in how fast you can do a bulk replacement in a large solution.Ā  We have achieved this by making incremental improvements in the last few releases.Ā  For example, by avoiding opening modified files while preserving the global undo capabilities, Async save, maximizing usage of caching & indexing. Stay tuned for continued performance enhancements to the Find and Replace experience.Ā 

Based on our measurements for the 95th percentile in Preview channel, 95% of Replace operations complete within 8 sec in 17.4 whereas they used to take up to 25sec in 17.3.Ā 

 

Image blog

 

Faster Indexing for C++ ProjectsĀ 

The time it takes to open a C++ project for the first time has significantly reduced. Large C++ projects could see a 20-35% speed improvement over 17.3 when populating the source code index used for colorization and IntelliSense.Ā Ā These performance gains come in addition to other improvements made in the previous release.Ā Ā Ā 

You can read more about the C++ IDE experience performance improvement hereĀ Ā 

Ā 

Reducing solution reloads during Git branch switchesĀ 

We reduced the number of branch switches that need solution reloads by an estimate of 80%.Ā  For example, when a developerā€™s change gets merged and reaches the main branch the rest of the team would have experienced a solution reload when switching to or from this branch. This scenario should no longer prompt a solution reload resulting in a faster branch switching experience.Ā  Ā 

These improvements come in addition to others made in the past few releases, which have reduced overall branch switch times measured at ~16 seconds in VS 2019 to ~10 seconds in VS2022 for the 95th percentile.Ā Ā 

Ā 

Image Branchswitching

 

.NET configuration switch responsivenessĀ 

We addressed issues related to switching configurations, such as changing from Debug to Release in the IDE. With these changes, Visual Studio is much more responsive after making such a switch.Ā 

Previously, when we switched configurations, we would completely tear down Roslynā€™s view of the project, then create a new one from scratch. This would result in re-parsing all source files in the project.Ā 

In practice, this new state would be very similar to the discarded one, with only a few differences.Ā 

Now, configuration switches reuse the existing Roslyn project, updating it with only the small delta between configurations. Consequently, Roslyn can do much less work to bring IDE features up to date for the newly selected configuration, reducing wait time.Ā 

The table below shows the performance improvements achieved between the two releases.Ā 

ImprovementsĀ  17.3Ā  17.4Ā  GAINĀ 
Inheritance MarginĀ  51.1 secĀ  26.6 secĀ  47.90%Ā 
ErrorsĀ  60.3Ā  27.8Ā  53.90%Ā 
CodeLensĀ  128.3Ā  38.2Ā  70.20%Ā 
Background tasksĀ  219.2Ā  89.9Ā  58.90%Ā 

Ā 

Unit Test PerformanceĀ 

Parallel Test discovery:

In solutions with multiple test projects, the Test Explorer now discovers the presence of tests in different test projects in parallel. This means tests are discovered and displayed in the Test Explorer much faster!Ā Ā  In our tests, we have seen test discovery complete twice as fast on a large solution with greater than 150 projects and close to 300K tests (on a machine with 10 CPU cores).Ā 

Efficient parallelization of test runs:

Test assemblies are now optimally parallelized across Target Frameworks and Architectures resulting in test runs that are three times faster on a large solution with greater than 150 projects.Ā 

Optimized communication between VS and test runner processes:

The test runner process connections are now established sooner. This means saving around 1 second on average per test assembly included in the test run. This leads to significant speed up for test runs involving a small number of tests. The communication between test runners and VS has also been tuned to be less chatty and more efficient. This leads to noticeable improvement especially for test discovery (up to 30% speed gain in many cases).Ā 

Ā 

Responsive File SaveĀ 

We moved most of the Save operations to a background thread allowing Visual Studio to stay responsive while documents are being saved. This enhancement is most noticeable when working on slow hard drives, network shares or editing exceptionally large files.Ā 

Ā 

Tell us what you think!Ā 

Ā We hope these performance enhancements make your development work efficient and enjoyable. Feedback from developers like you is very important for us to improve the product and meet your expectations. We welcome your feedback in the comments section of this Blogpost.Ā  You can also contact us at the Developer Community or via survey.

Author

Nayana Srikanth
Senior Product Manager

28 comments

Discussion is closed. Login to edit/delete existing comments.

  • Erik Thysell · Edited

    I experience VS 17.4.2 as slow, hangs a lot and often the menu stops responding: I can click on the menu row and options in any list but at times it stops from doing any thing after click. Every now and then I can only close VS by killing it from Task Manager (menu->File->Exit, Alt +F4, X in top right corner – none of it responds)

  • ls ls

    `by avoiding opening modified files while preserving the global undo capabilities` what is that? what is the global undo without opening files? is it something new? as a Vsixer (VS extender) I need EXACTLY this feature, where I can read how to use it in VSIX?!))

    • Oleg TkachenkoMicrosoft employee

      It’s not really new actually, it’s also called “linked undo” and you can use it via IVsLinkedUndoTransactionManager service.

  • Eli Black

    Lots of nice performance improvements here! The speedups when switching between branches and between .NET configurations are particularly welcome šŸ™‚

  • JiÅ™Ć­ ZĆ­dek

    Still miss Interactive C# against .net6/.net7 – since now we migrated almost all from .NET 4.6, C# interactive is almost useless….

  • Jefferson Motta

    I don’t know your scenario, but this last update makes the Find Files 5 times slower. Replacing all solutions takes ages. My PC is speedy but this latest update was a #fail.

  • Jason Baginski

    If things actually worked, this would be fantastic news. Since 17.4(including .1) I'm frustratingly having to exit and relaunch VS a dozen times a day due to https://github.com/dotnet/roslyn/issues/65064 It's been over a year of dealing with the find and replace deciding to switch to "Current document" rather than "Selection"(which I'm now told the race condition has been found and might be released in Feb 2023). Seriously, you can go as fast as you want, but if it means I'm having to constantly double check fields and restart VS, it's a net giant negative in my productivity and...

    Read more
  • Ajay Vijayvargiya · Edited

    Consider what's bread butter for a developer:
    * Code writing and Editing - sometimes the editor will freeze, will get out of focus and keystroke will go nowhere.
    * Debugging - Must be super-efficient - we aren't here to debug VS and report you the issues. We use VS to debug our programs!
    * Saving the files quickly - thanks for this and let's see how efficient it is now (hope it doesn't steal focus from editor to no-where)
    * Code Browsing must be really good, fast and accurate!

    Find and Replace, Branch Switching etc. are good, but IMO should...

    Read more
    • Damian Hallbauer

      I think the Git is too risky in dev studio.. I lost a ton of work by " bunting" an operaton from the UI its diteched mhy changes without warning . I use tortoise and the file manager for big commits.. its nicer but to stage a file shouuld be one pen touch or click.. it wants to commit everything by default. its llcleaner though and care should be taken that working on two pcs does actaulluy pull, merge and push to the top or defualt branch.. it was just...

      Read more
      • Nayana SrikanthMicrosoft employee Author · Edited

        Hi Damian,

        Thanks for the feedback. Could you please open a feedback ticket with clear steps with a video recording to reproduce the issue?

    • Keith Corser

      SSIS extension?

      • Ajay Vijayvargiya

        Did you reply on correct thread?

  • Dean Wrigley

    Upgraded to 17.4.1 and now intermittently unable to run Unit Tests because Test Explorer claims it can’t find any after a Run build – even though I can see all the tests loaded in the Test Explorer window with the total tests it has found shown in the flask button at the top. On previous days I have eventually managed to do something that made the tests be found after a build but Today it says 0 Tests no matter what I do. I’m going to uninstall and install an earlier version.

    • Abhitej John BandiMicrosoft employee

      Thanks for reaching out Dean. We've released a fix for a similar symptom in 17.4.2. There might be a few other cases tied to the version of xunit/nunit that could be causing some of these issues. If you are using those test frameworks, would you mind upgrading to the latest version of the adapter and give it a shot please? The other feedback that we are actively working on that could cause this is being tracked here and it's tied to running tests on a localized VS instance. We'd be extremely grateful if you could let us know if either...

      Read more
  • Jarosław Jasiński

    17.3 was really stable and fast. But 17.4 is so slow that I had to turn off ‘Background code analysis’.

    • Damian Hallbauer

      i think 17.5 got wayyy too slow lwo to type and tried live code analsysis.. off… mabye i missed that setting if its differnt .. to 17.4 rollback is ok for me…

    • Hugo Ribeiro

      17.3 is not fast in my opinion. Code analysis is slow and hangs the CPU a lot.
      The process ServiceHub.RoslynCodeAnalysisService.exe is always very busy (between 10% and 20%) even as I write these lines and Visual Studio is not in the foreground.
      This is THE area that needs to improve the most!

      • WM Z · Edited

        As an extension developer who keeps track of the new version of VS, I’ve posted the issue about the ServiceHub.RoslynCodeAnalysisService.exe before 17.4 was released publicly, with the detail and even stack trace about the problem, one month ago, however they were too slow to realize the problem and released the version despite of the problem.
        The fix was said to have been implemented two weeks ago, but not released at this moment.

        Now they are part of our environment destroyers.

      • Miles Merckel

        VS 2022 has a ferocious appetite for RAM. Each of my projects uses 1.5GB to 2GB or ram, if I try and open up a second project ram use is pushed to near 100% (my machine only has 16GB) then virtual ram on disk is utilised rendering my machine unusable.

      • WM Z

        It took me hours to identify the problem and eventually I found that it was VS’s fault. It is another story than the aforementioned ServiceHub.RoslynCodeAnalysisService.exe.

        The memory leak lies in the WPF part of VS which fails to release resources consumed by a code document window.
        Since each document window has some connection with the Roslyn code tree, you will eventually have scores of millions of syntax nodes unreleased in the VS instance. It is the reason why its appetite is so good.

      • Damian Hallbauer

        cna u just kill the service? or dispable live anaysis? i tried it and it didndt help…

        i try to kill lots of services when a build target is locked for a while as well.. its hard to see whtats locking my exe…

  • Muhammad Miftah

    Visual Studio's UI still remains painfully slow. The underyling WPF that VS uses is still the regular .NET Framework one. I mean, MS has already ported C++/CLI to .NET Core on Windows at least; why does VS still use .NET Framework's WPF?

    Closing a solution is still painfully slow. Rider closes a solution in a few milliseconds, but VS still manually 'unloads' each and every project and can take a whole minute to close a sln with more than 2 dozen loaded projects.

    Switching between debug and regular code editing views can still take several seconds. Sometimes hitting the restart-debugging button hangs...

    Read more
    • Damian Hallbauer

      Yes i agree.. its obvious that typing became super slow in text edtior in the lsat update. had to roll back to 17.4

      FINALLY AFTER I BEGGED, i got the fix for surface pen ,drag and drop that works in Notepad, sleect some code and drag and drop it, durnig debug that is so important. you often just and to move a line of code up or something. i never want to touch the hot keyboard and i wnat to use tablet and touch more.. I love the surface laptiop studio becasue theres no...

      Read more
    • Ajay Vijayvargiya

      I agree to this. All these operations are damn slow. I wish the performance/speed of VC6 (yes, VC6) is brought back to the latest one. CPUs are 100x faster, but VS is 10x slower than VC6!