dotnet / dotnet/runtime

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

Open
#123,124 47 comments 5 reactions 2 assignees Claimed by @AaronRobinsonMSFT View on GitHub
arch-x64 area-VM-coreclr os-windows tenet-performance
Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Description

### 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](https://github.com/user-attachments/files/24587095/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?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.