Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,866
    • Issues 4,866
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 455
    • Merge requests 455
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #18421
Closed
Open
Created Jul 03, 2020 by Andreas Klebinger@AndreasKDeveloper

WW can result in less inlining.

Summary

While looking at !2575 (closed) I realized that WW can decrease the likelihood of a function being fully inlined.

Which in turn might end up introducting higher order calls when they were known calls before or other undesireable things.

Consider these two functions, one with a strict dictionary.

data Dict = Dict { method :: (Char -> Bool) }

myFunction :: Num a => ((Char -> Bool) -> (a -> a) -> t1 -> t2 -> t3) -> Dict -> t1 -> t2 -> t3
myFunction f dict a b = f (method dict) (\x -> x+1) a b

myWWedFunction :: Num a => ((Char -> Bool) -> (a -> a) -> t1 -> t2 -> t3) -> (Char -> Bool) -> t1 -> t2 -> t3
myWWedFunction f method a b = f method (\x -> x+1) a b

For the original variant we get guidance of Guidance=IF_ARGS [60 60 20 0 0] 150 0}]

For the worker of myWWedFunction it's Guidance=IF_ARGS [60 60 0 0 0] 140 0}]

While the size of the worker decreased by 10, the discount for a evaluated dictionary argument also decreased by 20. This means it's overall less likely for the function to be inlined if WW is applied to the dictionary.

WW is clearly beneficial in this case. But it's somewhat annoying that it might make performance worse down the line.

Maybe we could give a discount if inlining turn unknown into known calls.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking