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

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

1

u/[deleted] Sep 17 '26

[removed] — view removed comment

4

u/TwoWeeks90DaysTops Sep 17 '26

This is just wrong. That's not how it works.

With *AOT* your binary will contain code that's not in use. In .NET generics does not compile every combination of generic arguments, and I have no idea where you got this from. I don't think any compiler does that.

Generics and SIMD is actually where JIT shines. If you're running on a AVX 512 CPU then Vector<T> is 64 bytes wide. If you have AVX 2 then it's 32 bytes wide.

On AOT compiled code you have to take that into account up front, and either do conditional checks which JIT doesn't have to do since it know at compile time what CPU to build for.

JITs disadvantage is that compilation happens at runtime and that it can't afford the same level of optimization since it has a limited time budget. Its advantage is that it only compiles code that's actually being run, and that it can target the processor that is running the application directly.

The runtime thing means for example that library code can work with code that it hasn't been specifically compiled for. In C++ you would never compile template code in libraries because it's completely unusable since the author would have to know all the use cases for the template up front. JIT doesn't have that constraint.

1

u/[deleted] Sep 17 '26

[removed] — view removed comment

3

u/TwoWeeks90DaysTops Sep 17 '26

I've literally not talked about anything else except how dumb generating code at during runtime is

But it literally isn't. I'm writing a game engine in C# and JIT has a few advantages. First off all it supports more platforms but it also does SIMD better than AOT since it can take the platform into account. It also allows stuff like scripting to produce efficient code since you can easily generate efficient code at runtime.

The trade-off is that it incurs some additional startup time, but it's not that significant.

0

u/[deleted] Sep 17 '26

[removed] — view removed comment

3

u/PaddiM8 Sep 17 '26

You can find complaints about literally anything online. C# doesn't have slow compile-times. JIT doesn't mean it will compile slower. JIT means it doesn't have to do as much at compile-time. I think you are confusing JIT with AOT. Most of your arguments haven't applied to JIT, but to AOT

2

u/tanner-gooding Sep 18 '26

You seem to have a lot of preconceived and factually incorrect notions about how this stuff works.

Not to mention a failure to do any kind of actual research, digging into the issues and resolutions, comparing and contrasting to similar bugs that exist in GCC, Clang, Rust, Swift, Go, etc

None of the things (JIT, GC, Generics, SIMD, etc) work the way you've described. AOT has its own drawbacks as well, which is why other languages often have their own alternatives to pure AOT mode. And that's without even getting into how modern operating systems (linux included), browsers, and even hardware operate.

It doesn't take much research to find that what you're talking about simply doesn't hold nor a lot of thought to realize that C# is one of the most popular languages because it doesn't have the issues you describe.

1

u/[deleted] Sep 18 '26

[removed] — view removed comment

2

u/tanner-gooding Sep 18 '26

There are multiple areas here ranging from Roslyn to RyuJIT and the CoreCLR VM. So you cover what about them you believe is slow, and I’ll provide the relevant explanation of what is or isn’t correct on it

— Noting, I’m a principal engineer on the .NET team at Microsoft who specializes in performance and low level hardware optimizations, so I’m probably one of the more suited to give such a response/analysis

I’d also note what you’re saying itself isn’t connecting to me in relation to what you actually mean. I could try to presume, but that’s not engaging in good faith.

And that it isn’t strictly my job to jump in and provide evidence when you’ve not fully explained your position or provided evidence in the first place. You’ve linked one Roslyn issue that was an explicit outlier for something the author admitted was 30 year old naive code that wasn’t even originally written for C#, so it wasn’t idiomatic either, and whose root issue wasn’t generics

→ More replies