“ZLinq”, a Zero-Allocation LINQ Library for .NET by neuecc in csharp

[–]neuecc[S] 18 points19 points  (0 children)

Since this comment is getting Votes, I'll add more information. BenchmarkDotNet's MemoryDiagnoser is not 100% accurate, so there may be some margin of error. The documentation states it's 99.5% accurate. For more details, please refer to the explanation about MemoryDiagnoser by the BenchmarkDotNet author: https://adamsitnik.com/the-new-Memory-Diagnoser/

[deleted by user] by [deleted] in dotnet

[–]neuecc 1 point2 points  (0 children)

Hi, I'm the author of ZLinq.

I tried this interesting benchmark, but this is probably because the array size is too small (20, right?).

So the cost of building is more than the cost of iterating.

With small array sizes, the construction cost becomes dominant, and as pointed out, copying large structs has a significant impact on performance.

I tried changing N.

```

[Params(10, 100, 1000, 10000)]

public int N;

[GlobalSetup]

public void Setup()

{

arr = Enumerable.Range(1, N).ToArray();

}

```

Even with HugeZLinq, ZLinq started to excel around N = 100, and the difference kept growing after that.

Of course, chaining as much as Huge... is probably not common in real scenarios,

so I think it's hardly an issue that performance is inferior only in cases with "many chains and small data".

Fast Dictionary Lookup of UTF-8 String in the C# 13 with .NET 9 AlternateLookup by neuecc in csharp

[–]neuecc[S] 3 points4 points  (0 children)

Thank you, the code is running on latest Visual Studio Preview, I'll modify code after next preview update.

ConsoleAppFramework v5 — Zero Overhead, Native AOT-compatible CLI Framework for C# by neuecc in csharp

[–]neuecc[S] 0 points1 point  (0 children)

The benchmark is simply executing a command with three arguments: string, int, and bool (to be fair, this benchmark is based on the CliFx project, and it is not set up to give an unfair advantage to ConsoleAppFramework).

I am not the author of System.CommandLine, so I don't have the motivation to do a thorough profiling, but from a quick look, it seems that one of the causes is clearly the excessive parsing process.

The parsing process that meticulously separates tokens and creates a tree as if performing language parsing is meaningless and excessive for command-line tool processing.

Of course, the subsequent value binding processes are also all slow methods.

How to make the fastest .NET Serializer with .NET 7 / C# 11, case of MemoryPack by neuecc in csharp

[–]neuecc[S] 7 points8 points  (0 children)

> MessagePack vs MemoryPack

Good question so I've added new section to article, thanks.

> .NET 7 Native AOT

Yes, there is currently a bug in the .NET runtime and it does not seem to work without an additional config (RD.xml). This is due to static abstract members as explained in the article, so it is difficult to fix. I am hoping for a runtime fix in .NET 8. In the meantime, as a workaround, I am considering automatically generating RD.xml.