Skip to content

Removing recursion in array.fs where it is may be worthwhile - #1439

Merged
KevinRansom merged 1 commit into
dotnet:masterfrom
jackmott:comparewith
Aug 16, 2016
Merged

Removing recursion in array.fs where it is may be worthwhile#1439
KevinRansom merged 1 commit into
dotnet:masterfrom
jackmott:comparewith

Conversation

@jackmott

Copy link
Copy Markdown
Contributor

I went through testing for opportunities to improve performance when recursive versions could be turned into explicit loops. For many cases it was a very small difference - 1% to 2%. If that is deemed worthwhile I can roll those into this PR (would include functions like pick, and find, etc)

compareWith got a 20% performance improvement so seems like an clear win. concat was a very small performance improvement, but I was also able to bring it down from 4 functions to just 2, so it is arguably simpler as well. I could pull this out though if the recursive implementation is preferred.

compareWith

MethodLengthMedianStdDevScaledGen 0Gen 1Gen 2Bytes Allocated/Op
Old1023.7544 ns0.3000 ns1.00---0.00
New1020.6222 ns0.2443 ns0.87---0.00
Old1000016,515.5425 ns137.0188 ns1.00---7.08
New1000013,171.2588 ns194.4002 ns0.80---7.09
Old10000001,741,685.5271 ns46,344.7793 ns1.00--2.0058,857.83
New10000001,430,355.4282 ns20,364.5100 ns0.82--1.0029,901.96

concat (where length is how many arrays are being concatted, each array being 5 elements)

MethodLengthMedianStdDevScaledGen 0Gen 1Gen 2Bytes Allocated/Op
Old10313.5194 ns6.8561 ns1.000.02--96.07
New10303.6155 ns3.8994 ns0.970.02--92.10
Old5000157,129.6265 ns2,104.6524 ns1.00--8.9641,074.92
New5000156,494.2465 ns4,158.5105 ns1.00--9.0541,470.82
Old50000017,492,839.3981 ns181,163.9916 ns1.0075.0075.0096.005,711,591.54
New50000017,198,734.2853 ns146,830.3554 ns0.9881.6777.5965.344,449,222.19

environment for tests

Host Process Environment Information:
BenchmarkDotNet=v0.9.8.0
OS=Microsoft Windows NT 6.2.9200.0
Processor=Intel(R) Core(TM) i7-4712HQ CPU 2.30GHz, ProcessorCount=8
Frequency=2240908 ticks, Resolution=446.2477 ns, Timer=TSC
CLR=MS.NET 4.0.30319.42000, Arch=64-bit RELEASE [RyuJIT]
GC=Concurrent Workstation
JitModules=clrjit-v4.6.1590.0
Type=SIMDBenchmark Mode=Throughput Platform=X64 Jit=RyuJit GarbageCollection=Concurrent Workstation 

@msftclas

Copy link
Copy Markdown

Hi @jackmott, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!
You've already signed the contribution license agreement. Thanks!

The agreement was validated by Microsoft and real humans are currently evaluating your PR.

TTYL, MSBOT;

@KevinRansom

Copy link
Copy Markdown
Contributor

@jackmott

This is great.

Thank you

@KevinRansom
KevinRansom merged commit 1d3409c into dotnet:masterAug 16, 2016
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@jackmott@msftclas@KevinRansom