-
Notifications
You must be signed in to change notification settings - Fork 316
WIP: Try to optimize in FCS #1197
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
Conversation
951b628 to
b4578c5
Compare
|
ok @dsyme was right. as always. The optimizer is exposing new TAST elements that Fable did never seen before ;-) but in other words: POC works |
|
looks like it's always ILAsm |
|
so the question is: |
|
@ncave @alfonsogarciacaro now I need help in the translation. |
|
@forki Is the BasicPatterns.ILAsm the only new element? |
|
@ncave at least it's the one that we see failing in the tests |
|
looks like ILAsm is the big new player. and then we have test failing with "Error: unexpected for-loop form" |
|
So far I've only seen ILAsm to check an array length in pattern matching, interpreting it required a lot of debugging and wishful thinking. Probably Fable wouldn't have been possible if there were many more cases of ILAsm in the AST, as parsing those expressions requires much more work and a knowledge of IL that I don't have. Please also note that the embedded IL code is not typed as they're just string literals. Personally I don't think handling an AST with lots of ILAsm is an option, though I've been proven wrong other times ;) |
|
that would leave us with option a) and we need to figure out how to tell Optimizer to no ILAsm all the things |
|
What do you mean? Which switch should I set?
Am 20.10.2017 16:52 schrieb "ncave" <notifications@github.com>:
… @forki <https://github.com/forki> Perhaps add to this
<https://github.com/Microsoft/visualfsharp/blob/master/src/fsharp/Optimizer.fs#L256-L272>
if not already there?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1197 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADgNId5fU39WclzcFKJxR-WFM3jyk_Xks5suLOigaJpZM4QAo6b>
.
|
|
@ncave so you are saying adding another option to FCS optimization that disables ilasm replacement is the way to go? |
|
@forki Well, if has to be added somewhere, the OptimizerSettings is as good a place as any. |
|
I have to say, adding the optimization phase to FCS/Fable is a fabulous idea, it has a lot of potential to be a big differentiator in the market and I hope we can make it work. I'm really excited about it, especially since the other options for code/perf optimizations are still not quite usable. Sometimes the best ideas are right there in the open, but somebody has to point them out. Bravo! 👏 |
|
@ncave I disabled FastIntergerLoopOptimization in FCS (as experiment) this should reduce number of failed tests dotnet/fsharp@07a30df |
|
mhm now I'm lost. I'm not sure where all the ILAsm stuff is coming from. /cc @dsyme? |
|
@forki Idk, perhaps everything else in TastOps.fs that returns |
|
doesn't seem to heal it. |
|
Here is a "optimize-able" REPL so you can try it live: https://ncave.github.io/fable-repl-test |
|
Awesome! |
|
I've been checking the REPL you set up @ncave and comparing it with Fable one. Really useful, thank you! In general the optimized version is emitting better code (when running the Ray Tracer the optimized version seems to get better times), sometimes it disables Fable optimization to flatten pipe chains creating extra closures (see capture, optimized code is on the right) but I guess this can be fixed. I think it makes lot of sense we release a version that offers this as an experimental option with a compiler flag :) BTW, did you also compiled FCS/Fable itself with the optimized version? Interestingly in your REPL FCS times seem to be faster but Fable times are slower. |
|
And I forgot to say the optimization also resolves the trait calls (inline functions with statically resolved generic parameters), which would have saved a lot of headaches 😉 |
|
Yes. I'm abs in favor of pushing this early under feature switch and
inverting default later in a minor or major release. I see so much
potential here.
Am 29.11.2017 08:04 schrieb "Alfonso Garcia-Caro" <notifications@github.com
…:
And I forgot to say the optimization also resolves the trait calls (inline
functions with statically resolved generic parameters), which would have
saved a lot of headaches 😉
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1197 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADgNP8cQDLqKMlfkfUDifSQY10LWxvEks5s7QHogaJpZM4QAo6b>
.
|
|
@ncave I updated this PR with the latest FCS optimizer. lot's of errors |
I assume these come from inlining operators like |
No, not yet, we need all the missing ILAsm translations added first, but it's close. |
|
@alfonsogarciacaro Update: Unfortunately still not as close as I hoped for.
It's up to you if you want to proceed with adding the (highly experimental) optimize compiler switch before fixing some or all of the above. I have submitted what I have so far to @forki 's PR so we should be on the same page once it's merged. Please note: |
|
I think we should at least have green test suite. I would then volunteer to
activate it on our production code and report all issues back as new tests
Am 30.11.2017 00:44 schrieb "ncave" <notifications@github.com>:
… @alfonsogarciacaro <https://github.com/alfonsogarciacaro> Update:
Unfortunately still not as close as I hoped for.
Here is a list of the outstanding errors introduced by the optimization
when compiling the tests:
- error FABLE: Cannot find replacement for:
Microsoft.FSharp.Collections.FSharpList::CompareTo
Microsoft.FSharp.Collections.FSharpList::Equals
Microsoft.FSharp.Collections.FSharpList::GetHashCode
Microsoft.FSharp.Core.LanguagePrimitives.ErrorStrings::InputArrayEmptyString
Microsoft.FSharp.Core.LanguagePrimitives.ErrorStrings::InputMustBeNonNegativeString
Microsoft.FSharp.Core.LanguagePrimitives.ErrorStrings::InputSequenceEmptyString
Microsoft.FSharp.Core.LanguagePrimitives.HashCompare::GenericComparisonIntrinsic
Microsoft.FSharp.Core.LanguagePrimitives.HashCompare::GenericEqualityIntrinsic
Microsoft.FSharp.Core.LanguagePrimitives.HashCompare::GenericGreaterOrEqualIntrinsic
Microsoft.FSharp.Core.LanguagePrimitives.HashCompare::GenericGreaterThanIntrinsic
Microsoft.FSharp.Core.LanguagePrimitives.HashCompare::GenericLessThanIntrinsic
Microsoft.FSharp.Core.LanguagePrimitives.HashCompare::PhysicalEqualityIntrinsic
Microsoft.FSharp.Core.LanguagePrimitives::GenericEqualityComparer
Microsoft.FSharp.Core.LanguagePrimitives::GenericEqualityERComparer
Microsoft.FSharp.Core.LanguagePrimitives::ParseInt32
Microsoft.FSharp.Core.LanguagePrimitives::ParseInt64
Microsoft.FSharp.Core.LanguagePrimitives::ParseUInt32
Microsoft.FSharp.Core.LanguagePrimitives::ParseUInt64
Microsoft.FSharp.Core.Operators.OperatorIntrinsics::PowDouble
Microsoft.FSharp.Core.Operators.OperatorIntrinsics::RangeChar
Microsoft.FSharp.Core.Operators.OperatorIntrinsics::RangeDouble
Microsoft.FSharp.Core.Operators::Failure
System.Array::Copy
System.Char::Parse
System.Decimal::Parse
System.Decimal::op_Explicit
System.Decimal::op_GreaterThan
System.Decimal::op_LessThan
System.Globalization.CultureInfo::get_InvariantCulture
System.Type::GetTypeFromHandle
- error FABLE: method only accepts a single argument:
System.Single.parse only accepts a single argument
System.Double.parse only accepts a single argument
-
hash of a string (i.e. hash "abc") for some reason results in an
unconverted ILAsm(["I_call"])
-
runtime error: "get_IsGenericType" is missing (in Reflection and Type
tests only).
It's up to you if you want to proceed with adding the (highly
experimental) optimize compiler switch before fixing some or all of the
above.
I have submitted what I have so far to @forki <https://github.com/forki>
's PR so we should be on the same page once it's merged. Please note:
OptimizedAssemblyContents has been renamed to
GetOptimizedAssemblyContents() from review.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1197 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADgNHEU9U90eKrgPCzfurdbCZNWMjGnks5s7exVgaJpZM4QAo6b>
.
|
2131301 to
5c323b3
Compare
66d8122 to
3c5ee07
Compare
|
@ncave what do we do with this one? |




Corresponding VF# PR: dotnet/fsharp#3784
/cc @dsyme @ncave