-
Notifications
You must be signed in to change notification settings - Fork 12
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
Lambda Lifting Chapter #63
Comments
Looking at https://input-output-hk.github.io/hs-opt-handbook.github.io/src/Optimizations/GHC_opt/lambda_lifting.html, I don't quite agree with the summary and heuristics suggested.
What is supposed to be the program here? Just a single call to
Both heap and stack are in memory and often in CPU cache, so there is little inherent difference in fetching time. That's not the point of lambda lifting. The original program allocates one (expensive) closure for The simplest motivational example for lambda lifting is map f = go
where
go [] = []
go (x : xs) = f x : go xs vs. map f [] = []
map f (x : xs) = f x : map f xs The first form is beneficial if there are few calls of FWIW the advent of join points tilted scales further in the direction of static argument transformation, letting GHC to do lambda lifting on its own. For instance, see discussion at haskell/bytestring#273 (comment). |
Hi Bodigrim, thank you for the review.
Yes I think this is much better guidance and I will add this language to the section.
Also great, this example should be very straightforward for the audience. I'll adapt the chapter to use this example. My motivation with the previous example was just to have the simplest program to show the transformation. But I do agree that the context of use for the function is an important and missing part.
Yes, this is not the point of lambda lifting per se but I still think it is an important point to make, because learning to read haskell with an performance eye is a skill in and of itself, and teaching that skill is one of the goals of the book. So my motivation here is not to say "GHC does this optimization that you should be aware of and here is how that works" but instead to say "Here is an optimization that GHC does, it may or may not fire, but you could consider performing the optimization manually in special cases".
Perfect! Join points is on the TODO stack so this will be a nice follow up chapter. I was thinking of doing SAT next because SAT is not enabled by default, is situational and is an effective optimization technique. |
Also I would like to add your name to the list of contributors as a reviewer. Is that ok with you? |
Sure, thanks. |
These are done. |
Tie this into the SAT chapter: #62
and have a discussion on use cases for the function being optimized. That is, answer when one might want to keep arguments on the stack with a lambda lift, and when one might want to SAT to avoid excess stack allocs.
The text was updated successfully, but these errors were encountered: