←back to thread

201 points olvy0 | 1 comments | | HN request time: 0.357s | source
Show context
EVa5I7bHFq9mnYK ◴[] No.41879253[source]
It's a shame, actually, that .NET performance improvements of up to x1000 could still be found after two decades and hundreds of millions spent on development.
replies(2): >>41879332 #>>41879654 #
eknkc ◴[] No.41879654[source]
Most of the time, it is not because there were too many slow things to be improved, it is mostly because they are adding more facilities to the runtime, enabling other performance improvements.

For example, the ReadOnlySpan type is a recent addition to the runtime and it will allow faster iterations when used. They simply enabled Linq to use it now.

replies(1): >>41880338 #
EVa5I7bHFq9mnYK ◴[] No.41880338[source]
ReadOnlySpan is a breakthrough innovative data structure, consisting of a pointer and a _length, that took Microsoft Corporation two decades to invent.

Well, better late than never.

replies(2): >>41880387 #>>41883634 #
neonsunset ◴[] No.41880387[source]
other languages do not have special pointers that can point to GC object interiors, be transparently addressed with arithmetics and cooperatively updated by GC without pinning, while also allowing to point to stack and unmanaged memory
replies(2): >>41880551 #>>41880632 #
int_19h ◴[] No.41880632[source]
But those pointers were around since .NET 1.0. Not only that, but things like e.g. ArgIterator were also there! Span could have been there too; it was really a matter of design rather than technical capability.

I think the main reason why C# didn't have this (and other low-level features like plain function pointers) for so long is because the original vision for .NET was that you'd mix and match different languages in your project as needed. So if you needed that kind of stuff, you'd reach out for managed C++ (and later, C++/CLI), while C# was kept deliberately more high-level.

And so once that approach was abandoned, C# needed to catch up to be able to play the "one language that can do it all" role.

replies(1): >>41884233 #
neonsunset ◴[] No.41884233[source]
'ret T's aka byref pointers aka managed references in their current form is a relatively recent addition. I can't seem to find which exact version but if my memory is correct - around .NET 5 or so, before that e.g. Spans had to use a specially annotated field with [ByRefLike] attribute. There wasn't really such a forefront support in both the language and the runtime to enable the user scenarios and even, if limited, ref escape analysis that are possible today. .NET 9 goes further and allows types that hold byrefs to be generic arguments, so you can now handroll your own "true" span-based LINQ-like code as well.
replies(1): >>41898827 #
1. int_19h ◴[] No.41898827[source]
The ability to have managed references as fields in types dates all the way back to 1.0. What's new is the ability to define custom ref types in verifiable code, but the runtime itself could always do so on a case by case basis - that is how TypedReference, ArgIterator etc have always worked.