Skip to content

Performance regression when running analyzers with .NET 10 #80756

@adiessl

Description

@adiessl

We have a fairly large solution containing around 70 projects, roughly split evenly between projects targeting .NET Standard 2.0, .NET Framework 4.8 and .NET 8. As .NET 10 is about to be released, we decided to upgrade our .NET 8 projects to .NET 9 first, before then upgrading them to .NET 10 via the release candidates 1 and 2 in order for us to be prepared for the final .NET 10 release.

In this process we noticed that building the solution on our CI server took way more time with the newer .NET releases compared with .NET 8. The following table shows the build times in minutes:

SDK Run 1 Run 2 Run 3
.NET 8 11:02 11:21 11:17
.NET 9 11:26 11:29
.NET 10 RC1 15:38 16:15 15:53
.NET 10 RC2 14:57 14:01

Since we are creating a .binlog file for every build, we had a look at them to determine the cause for this increase. Here are screenshots of the Analyzer Summary for each SDK (our own, custom analyzer is red in the screenshots):

  • .NET 8
    Image
  • .NET 9
    Image
  • .NET 10 RC1
    Image
  • .NET 10 RC2
    Image

What is standing out is that analyzers in the same version take over ten times as long with .NET 10 as they did previously. Two examples:

SDK SerilogAnalyzer Custom analyzer
.NET 8 00:51.395 00:19.397
.NET 9 01:00.710 00:19.351
.NET 10 RC1 12:59.549 11:20.161
.NET 10 RC2 10:18.767 04:53.101

To make sure this is not a problem with our setup or our huge solution, I created the following repository: https://github.com/adiessl/dotnet-analyzers

For completeness sake I will include the findings from its README.md here:

This repository contains four project files, each targeting a different .NET SDK.

All of them, however, are using the same Program.cs file as well as the same auxiliary classes to demonstrate a potential performance regression when it comes to the execution of analyzers during the build process.

In order to have reliable data, an analyzer is used that does not depend on the .NET version: SerilogAnalyzer (version 0.15.0.0)

To automate the testing process, the PowerShell script Run-Tests.ps1 exists in this repository. It ensures each build is started from a clean slate, creates an appropriate global.json file for the project before then building it. The build produces a .binlog file that can be used to analyze the performance.

These are the times that the SerilogAnalyzer has taken according to the Analyzer Summary in the MSBuild Structured Log Viewer:

SDK Run 1 Run 2 Run 3
.NET 8 0:34.684 0:48.367 0:43.041
.NET 9 1:04.883 0:48.083 0:55.658
.NET 10 RC1 1:22.098 1:25.574 1:40.713
.NET 10 RC2 1:43.268 1:38.671 1:36.506

Even though the times are fluctuating somewhat from run to run, it is obvious that the analyzer takes a lot more time in newer .NET versions.

I did not run the tests on our build server, but on my machine. Still, the analyzer takes a lot more time according to the .binlog files.

Is this a known regression? Is this the correct repository for filing this?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions