Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance improvements #5

Merged
merged 27 commits into from Nov 16, 2014
Merged

Conversation

manofstick
Copy link
Member

Fixed a number of issues with performance.

Project:

  • Added a mechanism using [ReflectedDefintion] that compares both output results and times of properly compiled code and linq compiled code. Added a "Performance" project configuration to run the time portion of these tests (it always runs the comparison code)

Expression Tree Creation:

  • Very slow when capturing state in Expression.Lambda calls; so compiled Expression.Lambdas individually and stored in objects which included captured state
  • Performance of basic operators was very slow because custom method was provided so I skip that in case of primitive types
  • Using Blocks in a couple more places

Analysis Time:

  • DerivedPatterns.SpecificCall was v. slow, so removed
  • A few other Expr tree manipulations; removing |> and |< and then fixing resultant tree
  • Removing op_Range and op_RangeStep as the offered functions are v. slow

Now in many cases get close to compile time speeds (so this library is actually semi-useable!), but could still do with another full round of examination as I know I have left holes, as well as missing functionality (recursive functions to name one big hole that I haven't peered down yet). Hopefully I'll make some time; but I'm pretty burnt out at the moment.

Paul Westcott and others added 27 commits November 3, 2014 19:31
Using Expression.Block to express let binding, which allowed support for
VarSet. Needed to changed Patterns.Sequential to use Expression.Block as
well.
Not sure if this is the greatest solution; but works.
The While loop code was called from other places, so moved the addition
of the Unit type up to there.
Documentation for Expression.GetActionType and Expression.GetFuncType
say they support arrays up to 16 & 17 respectively; so removed helpers
that duplicated such functionality.
Taking samples from [rosettacode](http://rosettacode.org/)
These are very generous timings to say the least! The linq compiled
versions are 30 or some times worse! Lets see what we can do about
that...
Operations on non-int types are abysmal!
Added tests; now need to fix...
If Lambdas don't require capturing extra state, then create an instance
of a class that derives from OptimizedClosures.FSharpFunc.
In normal Release build the Performance tests are now Ignored.
Just used a Expression.Block
@manofstick
Copy link
Member Author

@fsgit

Not sure if anyone is having a look at this; so maybe let me know if you want a stable merge point, or otherwise I'll just bleed things in as my time takes me...

Anyway, just as an example of the speed increase, the tests in FSharp.Quotations.Evaluator.Unittests on my machine previously took around 22 seconds, and now take ~ 1 second. (this was in the 64-bit JIT; in 32-bit JIT it previously around 8 seconds, now around 1.5 seconds)

...and in complex quotations, with a number of functions and currying, the improvements were much greater (although if there are more than 5 arguments or 8 captured variables then some of my optimizations drop back to original functionality; I could enhance this; these were just the easy values, have to think a bit more to increase these...)

@bleis-tift
Copy link
Contributor

In complex quotations that throw StackOverflowException, this PR solve the problem.

@manofstick
Copy link
Member Author

@bleis-tift

Thanks for that; shame I didn't branch from that version! I'll see how I go merging in it in my fork over the w/end.

@dsyme
Copy link
Contributor

dsyme commented Nov 14, 2014

Hi guys,

I think it would make sense to bring one of you on board to have the ability to accept pull requests and release nuget packages. Could you email myself (donsyme AT fastmail DOT fm) and @forki (sforkmann AT gmail DOT com) if you're interested

Thanks
Don

manofstick added a commit that referenced this pull request Nov 16, 2014
@manofstick manofstick merged commit eeb7199 into fsprojects:master Nov 16, 2014
Sign up for free to 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.

None yet

5 participants