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

Cleanup Optimizer #1519

Merged
merged 9 commits into from
Sep 20, 2016
Merged

Cleanup Optimizer #1519

merged 9 commits into from
Sep 20, 2016

Conversation

forki
Copy link
Contributor

@forki forki commented Sep 5, 2016

No description provided.

forki added a commit to fsprojects/FSharpPerf that referenced this pull request Sep 5, 2016
forki added a commit to fsprojects/FSharpPerf that referenced this pull request Sep 5, 2016
@forki
Copy link
Contributor Author

forki commented Sep 5, 2016

I wonder if FlatList should be removed completely!?

| 3 -> Some (DevirtualizeApplication cenv env cenv.g.generic_compare_withc_tuple3_vref ty tyargs (mkCallGetGenericComparer cenv.g m :: args) m)
| 4 -> Some (DevirtualizeApplication cenv env cenv.g.generic_compare_withc_tuple4_vref ty tyargs (mkCallGetGenericComparer cenv.g m :: args) m)
| 5 -> Some (DevirtualizeApplication cenv env cenv.g.generic_compare_withc_tuple5_vref ty tyargs (mkCallGetGenericComparer cenv.g m :: args) m)
| _ -> None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This diff duplicates code - it doesn't seem right unless we know for sure it gives a measurable performance win.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that idea was stupid. Reverting later

Am 05.09.2016 18:31 schrieb "Don Syme" notifications@github.com:

In src/fsharp/Optimizer.fs
#1519 (comment)
:

  •    let vref =
    
  •        match tyargs.Length with
    
  •        | 2 -> Some cenv.g.generic_compare_withc_tuple2_vref
    
  •        | 3 -> Some cenv.g.generic_compare_withc_tuple3_vref
    
  •        | 4 -> Some cenv.g.generic_compare_withc_tuple4_vref
    
  •        | 5 -> Some cenv.g.generic_compare_withc_tuple5_vref
    
  •        | _ -> None
    
  •    match vref with
    
  •    | Some vref -> Some (DevirtualizeApplication cenv env vref ty tyargs (mkCallGetGenericComparer cenv.g m :: args) m)
    
  •    | None -> None
    
  •    match tyargs.Length with
    
  •    | 2 -> Some (DevirtualizeApplication cenv env cenv.g.generic_compare_withc_tuple2_vref ty tyargs (mkCallGetGenericComparer cenv.g m :: args) m)
    
  •    | 3 -> Some (DevirtualizeApplication cenv env cenv.g.generic_compare_withc_tuple3_vref ty tyargs (mkCallGetGenericComparer cenv.g m :: args) m)
    
  •    | 4 -> Some (DevirtualizeApplication cenv env cenv.g.generic_compare_withc_tuple4_vref ty tyargs (mkCallGetGenericComparer cenv.g m :: args) m)
    
  •    | 5 -> Some (DevirtualizeApplication cenv env cenv.g.generic_compare_withc_tuple5_vref ty tyargs (mkCallGetGenericComparer cenv.g m :: args) m)
    
  •    | _ -> None
    

This diff duplicates code - it doesn't seem right unless we know for sure
it gives a measurable performance win.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/Microsoft/visualfsharp/pull/1519/files/28119521a9117c8dd2c8b7552576c56be57fe052..837bfc2b134d02bca14d47789145f2f5ed6ca1b3#r77542728,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AADgNMPGJtTgy1SbVzXIejHwwLjJ4XJtks5qnEPcgaJpZM4J1Jn3
.

forki added a commit to fsprojects/FSharpPerf that referenced this pull request Sep 5, 2016
forki added a commit to fsprojects/FSharpPerf that referenced this pull request Sep 5, 2016
forki added a commit to fsprojects/FSharpPerf that referenced this pull request Sep 6, 2016
@forki forki force-pushed the optimizer2 branch 2 times, most recently from 8e09ca3 to ee0baed Compare September 6, 2016 06:56
forki added a commit to fsprojects/FSharpPerf that referenced this pull request Sep 6, 2016
forki added a commit to fsprojects/FSharpPerf that referenced this pull request Sep 6, 2016
@forki forki changed the title WIP Cleanup Optimizer Cleanup Optimizer Sep 6, 2016
@forki
Copy link
Contributor Author

forki commented Sep 6, 2016

ready for review

forki added a commit to fsprojects/FSharpPerf that referenced this pull request Sep 6, 2016
| _ -> args |> List.map (fun _ -> UnknownValue)

let args',arginfos = OptimizeExprsThenReshapeAndConsiderSplits cenv env (List.zip shapes args)
| Expr.Val(vref,_,_) ->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@forki, I actually prefer the when clause on this pattern match it eliminates the duplication.

Does that make sense?

Kevin

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah but then you pattern match twice

@KevinRansom
Copy link
Member

looks good to me.

@dsyme
Copy link
Contributor

dsyme commented Sep 20, 2016

One timeout failure on AppVeyor, unrelated to PR:

[00:45:27] 1) Failed : FSharp.Core.Unittests.FSharp_Core.Microsoft_FSharp_Control.AsyncModule.AwaitWaitHandle.Timeout
[00:45:27]   Delta is too big 969
[00:45:27]   Expected: True
[00:45:27]   But was:  False

let binfos = minfos |> List.choose (function Choice1Of2 (_,x) -> Some x | _ -> None)
let minfos = minfos |> List.choose (function Choice2Of2 x -> Some x | _ -> None)

let mbinds = List<_>()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer the original immutable code here. TMDefRec is relatively rare so I'm certain this doesn't dominate CPU perf.

(BTW if we were to use a mutable list, then please use ResizeArray)

@dsyme
Copy link
Contributor

dsyme commented Sep 20, 2016

This looks OK

Re FlatList - yes, it's just alias for List. The belief once upon-a-time was that the pervasive use of linked lists (List) instead of flatter data structures (Array, ImmutableArray etc.) was hurting. So we added an alias FlatList for certain use of Lists where it felt there would be a perf gain for switching to a flat data structure. However when switching to a flat data structure we didn't see any real perf gains. However we left FlatList in just in case we wanted to try again. So it's still unclear if we should rip it out for simplicity, or try to resurrect the experiment. I'm OK with ripping it out at this stage I suppose since the experiment has been dormant so long.

@KevinRansom KevinRansom merged commit ca69e01 into dotnet:master Sep 20, 2016
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.

4 participants