Skip to content

Severe performance regression in .NET 10 vs .NET 9 for xUnit v3 test execution #123124

@Schaeri

Description

@Schaeri

Description

After upgrading our solutions from .NET 9 to .NET 10, we observe a ~80–90% slowdown when executing xUnit v3 tests using the xUnit v3 In-Process Runner (direct EXE execution, not dotnet test or with dotnet run).

Profiling shows that the regression is mostly in gc and system code.

With a simple sample test project, we can demonstrate the problem.

Configuration

  • .NET SDK: 10.0.101
  • .NET Runtime: 10.0.1
  • Comparison baseline: .NET 9.0.11
  • Windows x64
  • xUnit.net v3.2.1
  • xUnit v3 In-Process Runner
  • Tests executed by directly running the compiled test EXE with dotnet run
    (not via dotnet test, no Microsoft Testing Platform)

Analysis

PerformanceNet9vsNet10Tests.zip

The sample project contains 10,000 test classes, all of which are copies of test class 1. These generate a certain amount of memory and CPU load.

Using run.bat, the tests are executed first on .NET 9.0 and then on .NET 10.0—once in Debug mode and once in Release mode.

.NET 9.0 Debug: 2.103 s vs .NET 10 Debug: 4.9 s
.NET 9.0 Release: 2.137 s vs .NET 10 Release: 5.254 s

The execution time increases significantly in all cases.

JetBrains dotTrace output
Settings: Sampling, Realtime CPU Instruction

Image

Top Hotspots in the System namespace:

Image

This issue leads to increased build pipeline wait times and higher costs. What mitigation options are available? Could this be a runtime-related problem associated with the optimizations in .NET 10?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions