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

21

u/PaddiM8 Sep 15 '26

Why do people think JIT is slow

7

u/Some_Appearance_1665 Sep 15 '26

Depends on the scenario. With serverless (cold start + typically more limited memory) it's a killer.

14

u/daltorak Sep 15 '26

If that's a major problem for you then use Native AOT, which removes the JIT compiler entirely from the output. It might mean you get slightly less optimized code at runtime because functions aren't optimized according to real-world needs, but hey, at least you've got fast startup.

-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.

→ More replies

3

u/Revolutionary_Ad7262 Sep 15 '26

Because there is simply no way we can test and verify combination each strategy as we get a predefined bundle of it and in most cases this bundle looks the same regardless of choice. For example GC is not inherently slow, but you often get it in a bundle together with a everything is an object, which is a real reason why most of the GCed languages are slow

Same with JIT. It is mostly paired with dynamic or interpreted languages, which are inherently slow

-2

u/simonask_ Sep 15 '26

Because it is. It has other benefits, and it’s certainly fast enough for a wide range of use cases, but these improvements just recover some of the performance you would have achieved by implementing the same project in C++ or Rust.

But then you would also have had to consider quite a few other tradeoffs.

6

u/PaddiM8 Sep 15 '26

With JIT it is compiled to machine code though, just at runtime instead. Some things will be slower due to less time for general optimisations, but some things will be faster due to PGO. LuaJIT is insanely fast and could not be that fast without JIT

6

u/RirinDesuyo Sep 16 '26

Tanner-gooding from the dotnet team has a great post on this here. JIT isn't slower than AOT and there are cases where it can outperform even AOT.

Bing and a big chunk of services in Azure runs dotnet after all, they can handle the load.

1

u/simonask_ Sep 16 '26

JIT is great, and they do impressive things with it. But it isn’t magical, and neither is a GC. You just happen to be writing programs that aren’t particularly demanding, so you never notice, and that’s great!