Skip to content
This repository has been archived by the owner on Oct 3, 2019. It is now read-only.

Added Cistern/System Linq plus change to array #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

manofstick
Copy link

Hi @agocke

Not really much of a serious pull request, more just a point of contact, given that you have been interested in IEnumerable and performance...

Anyway, first things first... a little critique of your code... you are not replicating the functionality of List<>.Enumerator (in fact it can't be) because you are not honouring the "version" number. This is used if the collection is modified which enumerator is occurring (i.e. this protects where a Count might initially be requested, which would allocate a buffer, and then the collection has it's size changed... maybe? Anyway, it is functionality that exists that your enumerator doesn't support). So I changed the structure to an array which doesn't suffer from this...

So secondly.... I have been working on a replacement for Linq-to-objects called Cistern.Linq (as well replacing F#'s Seq, built on top of that). It's not complete, but functionality has been copied from (or forwards calls to) the original implementations, so it should be 100% functional (albeit, probably bug ridden! Although it does run the corefx linq and fsharp seq test suites...)

So just for "show" I added it to your benchmark suite, where it beats everything (by cheating basically, optimized for SIMD), but that is really just an edge case...

Method Mean Error StdDev
ForLoop 125.6 us 1.9489 us 1.8230 us
ForEachLoop 111.3 us 0.8483 us 0.7935 us
CisternLinq 103.2 us 1.9651 us 1.8381 us
SystemLinq 842.1 us 10.0513 us 9.4020 us
ForeachIEnumerable 842.7 us 12.9294 us 12.0942 us
FastEnumerable 179.9 us 1.1849 us 1.0504 us
MyListFastEnumerable 241.5 us 3.5694 us 3.3388 us
IFastEnumerable 545.4 us 8.1830 us 7.2540 us
IFastEnumerableGeneric 205.8 us 3.8678 us 3.7987 us
FastEnumerator 185.9 us 3.6832 us 4.2416 us
MyListFastEnumerator 183.3 us 2.1944 us 2.0526 us
IFastEnumerator 547.0 us 5.2208 us 4.0761 us
IFastEnumeratorGeneric 400.3 us 6.4592 us 6.0419 us

You can see some other comparisons to LinqOptimizer which also point to this file, or to LinqFaster or you can have a peruse in the source code in the benchmarks project where benchmark results have been added in source control, such as this.

Anyway, it's "90% finished", which given it's deep roots means I'll be finished sometime around 2022...

But hey, you never know. I've been trying to spark anyone's interest for years... Maybe you'll be the one :-)

@agocke
Copy link
Owner

agocke commented Oct 2, 2019

Thanks, this is cool! I wasn't really trying to replicate LINQ exactly, more trying to figure out where the optimization strategies worked and where they didn't.

I'm probably not going to continue with this idea because I'm not sure adding a new interface is even a good idea anymore.

Cistern sounds good though. If it really is functionally identical and is faster you should try proposing changes in CoreFX. Any further changes I make will probably be in comparison to existing CoreFX code.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants