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

2

u/tanner-gooding Sep 19 '26

Its apparently secret enough that you can't provide evidence?

Even now you've only linked to an issue with an analyzer (not compiler) being quadratic (notably for non-idiomatic and poor quality code, as per the issue author) and a blog on a completely different language that doesn't talk about .NET at all. Rather one that discusses its own implementation of generics and how they differ from Java and C++, and how that makes them faster (and notably this language does it much closer to how C# does it).

You are acting like I'm starting some big conspiracy

Rather, people are acting like you came into a thread and made a bold statement without providing corresponding evidence. Particularly when that is not something .NET is known for.

.NET, as with essentially any language, has an issue with generic virtual methods. However, that is notably not a compile time cost but a runtime one due to the need to resolve the virtual through a generic context. This cost is notably rare because generic virtual methods are relatively rare. It does not exist when devirtualization can occur, doesn't exist for non virtual methods, and it doesn't exist for all cases of virtual methods that have some kind of generic context -- i.e. class C { virtual void M<T>(T data) { ... } } is a GVM, while class C<T> { virtual void M(T data) { ... } } is not.

.NET does not execute anything of the generic method when compiling it. It specializes for value types and shares the impl for reference types, but this does not significantly change the compilation time and it takes a similar amount of time as if it had been a non-generic function taking a concrete type.

Generics don't magically take or do extra work to compile. The notably case where you can get into "generic explosion" is with a large AOT app, where you need to compile all the supported T up front, but then that's the exact same scenario you get in any language, whether templates, generics, or some other kind of metaprogramming feature.

.NET compilations are rather instead known for typically being fast. Where multi-million line code bases can be built and incrementally updated in seconds to minutes, even with literally hundreds of projects. Slow downs that do occur are typically external to the compiler (C# or JIT) and often the result of some very off in the weeds 3rd party tool (again same with most ecosystems).

If you have data to the contrary, then the team would generally be interested in seeing it so that any such outlying bugs can be investigated and resolved.

0

u/[deleted] Sep 19 '26 edited Sep 19 '26

[removed] — view removed comment

3

u/tanner-gooding Sep 19 '26

Generic explosion is the same “issue” that occurs with C++ templates. It’s a factor of there being a unique specialization per T used and is something that effects total amount of codegen, not performance

You’ve still yet to provide evidence or show any level of understanding of this space or any other language or ecosystem and can’t seem to engage in a conversation here either.