Zero allocation LINQ with Span and LINQ to SIMD, LINQ to Tree (FileSystem, Json, GameObject, etc.) for all .NET platforms and Unity. - Cysharp/ZLinq
I've recently discovered this project, which assuming it works as advertised (which I think wasn't really tested yet, since it seems to be a pretty new repo) sounds like a pretty good library to add into your toolbox.
For those that do not know, LINQ is basically a query language over collections in C#, that allows you (from the top of my head) to do stuff like
which would give you a IEnumerable list with names of elements where value is smaller than 10, ordered by priority.
However, using LINQ in performance critical code, such as per-frame Updates, is not really a good idea because it unfortunately does generate a lot of garbage (allocations for GC to collect). Having a version that doesn't allocate anything sounds awesome, assuming you are a fan of LINQ.
What are your thoughts? For me, it sounds like something really useful. While it's not really that difficult to avoid LINQ, I'm a fan of the simplicity and descriptive nature of the syntax, and not having to avoid it would be great. It does seem there are quite a few issues starting to pop up, but it's definitely a project that could be worth it to follow.
I've never heard of them, but a colleague told me he recognized the name and thought that they do middleware that's extremely expensive. Haven't looked into it, but their FOSS stuff looks nice.
Have you worked with their other/older projects? I'd be interrested in someones experience with this developer, if it's something that can be reasonably trusted.
Kissaki provided a neat list. Of those I've used UniTask extensively and is a game changer. It's a must have if you are using threading, as it forces single threads on platforms where is unavailable, without compromising performance in the others. We have a game on iOS and Android, with a lot of threading work involved to load bazillions of things, but webgl doesn't support threads, so adding it as a platform presented an interesting challenge. Switching our threading to UniTask instead of native Tasks makes it possible to not change our code or having weird #if UNITY_WEBGL flags scattered around virtually everywhere to toggle threading. And the zero allocation tasks are awesome. And it has a lot of interop and extensions to neatly integrate with Unity better than the native tasks, while not breaking the native interface.
If you're using Entity Framework for the mssql, I doubt that this library would work as a substitute.
Because that linq gets parsed into expression trees and then send to the underlying provider (mssql/mysql etc) to be converted into sql. So if you you some non-standard library those providers won't be able to convert that linq to sql
Yeah, that was ma understanding/assessment as well. It could be useful for my other use case of reading from linear byte data spans though. I suspect the dependency overhead won't be worth for what it provides though when I can go over the span myself. We don't have many query-condition-like aspects to reading it.
Honestly, I don't really see a reason why anyone would need to be running LINQ every single frame, even if it performed better. I like the idea that this performs better, but that specific use case I don't see a benefit over using the builtin solution, since IMO you shouldn't really ever need to do that anyways.
I can imagine a few use cases, sorting or selecting or filtering a list is something that does pop up from time to time. It's nothing major, and definitely not a must have.
From the top of my head it can be finding a closest enemy to the player, while it doesnt have to be done every frame, you'd want to do it often enough.
Sure, you can just for loop it (as with any LINQ calls), but I'd say that LINQ is more readable.