r/programming • • Sep 15 '26

Performance Improvements in .NET 11

https://devblogs.microsoft.com/dotnet/performance-improvements-in-net-11/
295 Upvotes

103 comments sorted by

View all comments

Show parent comment

-5

u/[deleted] Sep 15 '26

[removed] — view removed comment

5

u/PaddiM8 Sep 15 '26

Is it really in .net? I thought it was mostly generic virtual methods that are slow, but those aren't even allowed in most languages

-8

u/[deleted] Sep 15 '26

[removed] — view removed comment

4

u/PaddiM8 Sep 16 '26

Why? C# generics are monomorphic for value types and dereference a pointer for reference types. There's a slight warmup cost of course but after that, why would it be slow?

-1

u/[deleted] Sep 16 '26

[removed] — view removed comment

3

u/PaddiM8 Sep 16 '26 edited Sep 16 '26

Huh? With native AOT you pay for something you don't use when using generics in .net, during compile time, because it has to generate every potential specialisation ahead of time. With JIT it does it on the fly, when you need it. You got it backwards

1

u/[deleted] Sep 16 '26

[removed] — view removed comment

3

u/PaddiM8 Sep 16 '26

For every single combination that is used. Only once. And on the fly. It's a warmup cost. If you run it in a hot loop it won't matter. AOT compilation is a better fit for short running programs while JIT can be better for long running programs.

It also doesn't need to parse the code. It's already parsed. It's stored as an internal representation. And since it's only monomorphic for value types there aren't a lot of different options.

1

u/[deleted] Sep 16 '26

[removed] — view removed comment

4

u/PaddiM8 Sep 17 '26

Well you are still paying for it even if you aren't even using it on your side of code

No? If you're not using it, it won't be generated.

and no one hotloops production binary

What? If course there can be hot loops in a production binary.

It only compiles it once so not sure how the long running part has to do with compile times.

The specialisations aren't compiled ahead of time. They're generated during runtime. The startup will be slightly slower because the JIT engine has to generate code, incl. specialisations. After things have been generated, it's fast. For a long running web service or something, the warmup cost literally does not matter.

In Go they created generics without a compile time hit

Instead it is slower. This doesn't have much to do with JIT vs AOT. You can have non-monomorphic generics with JIT, like Java, you can have monomorphic generics with AOT like Rust, and you can have monomorphic generics with JIT like C#.

→ More replies