Skip to content

.NET 5 performance regression (~10%) from .NET Core 3.1 #36907

Description

@Sergio0694

Description

I have a .NET Standard 2.0 library implementing a high performance interpreter for the brainf*ck language. At the end of the day it is essentially just a Turing machine, so all the operations being performed are basically accesses to memory, incrementing values, looking up tables, etc. It's all "self-contained", with no external APIs being invoked, IO operations or anything.

I've run some benchmarks on .NET Core 2.1, .NET Core 3.1 and .NET 5 (Preview 4) and noticed that .NET 5 is consistently slower than .NET Core 3.1 in almost all cases. Especially in the mandlebrot test case, which is the most intensive, .NET 5 is almost one second slower, so about 10% slower.

I find this very surprising, as .NET 5 is supposed to be much more optimized than .NET Core 3.1.

NOTE: the solution is not open source for now, but I'd be more than happy to give access to the repo to anyone in the team wanting to take a look, just ping me and I'll send you the invite.

Pinging @EgorBo as you seemed interested in this when I shared some older benchmarks about this on Twitter (here) back when .NET 5 preview 1 had just been released, and cc. @tannergooding.

Configuration

BenchmarkDotNet=v0.12.1, OS=Windows 10.0.19619
Intel Core i7-8750H CPU 2.20GHz (Coffee Lake), 1 CPU, 12 logical and 6 physical cores
.NET Core SDK=5.0.100-preview.4.20258.7
[Host] : .NET Core 5.0.0 (CoreCLR 5.0.20.25106, CoreFX 5.0.20.25106), X64 RyuJIT
.NET Core 3.1 : .NET Core 3.1.4 (CoreCLR 4.700.20.20201, CoreFX 4.700.20.22101), X64 RyuJIT
.NET Core 5.0 : .NET Core 5.0.0 (CoreCLR 5.0.20.25106, CoreFX 5.0.20.25106), X64 RyuJIT

Regression?

This is a regression in speed from .NET Core 3.1 to .NET 5 Preview 4, on the same machine.

Data

RuntimeNameMeanErrorStdDev
.NET Core 2.1Division56.82 us0.810 us0.758 us
.NET Core 3.1Division41.06 us0.588 us0.521 us
.NET Core 5.0Division42.95 us0.511 us0.453 us
.NET Core 2.1Fibonacci21,298.13 us398.437 us372.698 us
.NET Core 3.1Fibonacci13,197.50 us65.613 us58.164 us
.NET Core 5.0Fibonacci15,302.14 us83.934 us78.512 us
.NET Core 2.1HelloWorld17.61 us0.296 us0.341 us
.NET Core 3.1HelloWorld16.09 us0.311 us0.394 us
.NET Core 5.0HelloWorld15.68 us0.305 us0.510 us
.NET Core 2.1Mandelbrot10,221,974.39 us131,372.509 us116,458.307 us
.NET Core 3.1Mandelbrot7,799,742.74 us65,822.677 us58,350.088 us
.NET Core 5.0Mandelbrot8,544,272.25 us8,136.804 us7,611.172 us
.NET Core 2.1Multiply1,204.57 us14.566 us12.912 us
.NET Core 3.1Multiply792.31 us5.899 us4.926 us
.NET Core 5.0Multiply790.11 us1.301 us1.087 us
.NET Core 2.1Sum52.86 us0.590 us0.493 us
.NET Core 3.1Sum39.53 us0.620 us0.580 us
.NET Core 5.0Sum37.39 us0.470 us0.417 us

category:cq
theme:jit-block-layout
skill-level:expert
cost:large

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMItenet-performancePerformance related issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions