0:00 / 0:00
Laziness in Haskell — Part 4: Thunks
Tweag by Modus Create
5K subscribers • 25 videos on Hallway
- Recommended by 1 person: 1 in engineering communities.
- Presented by Alexis King
Advanced. Deep dive for people who know the field.
5.4K views3 years ago1 recommendation
Programming languagesSystems programmingHaskellPerformance and optimizationMemory management
Alexis King explains how GHC introduces thunks to implement laziness, when thunking acts as an optimization, and why unnecessary thunks occur.
It is finally time to take a look at how GHC introduces thunks to implement laziness. We first consider ways that thunking can sometimes be viewed as an optimization, then try to understand the source of unnecessary thunking in most Haskell programs. Effects for Less: youtube.com/watch?v=0jI-AlWEwYI The worker-wrapper transformation: youtube.com/watch?v=XiTO1EGKrhE Part 1: youtube.com/watch?v=fSqE-HSh_NU Series Playlist: youtube.com/playlist?list=PLyzwHTVJlRc8620PjqbM0x435-6-Gi1Gu — Contact: • Tweag Website: tweag.io/ • Tweag Twitter: twitter.com/tweagio • Alexis King's Twitter: twitter.com/lexi_lambdaWhy it's here
1 person recommends thisWhat people say. Recommended as a clear and detailed explanation of how thunks work in GHC and how they affect memory and performance.
Moments people linked to
u/Faucelmein r/haskell • Mentions
On “Fast Haskell, Redux”
IIUC, in this video Alexis King seems to make a somewhat contrary point when she says that if a function returns a tuple, and it's unlikely that only one of the members of the tuple will be evaluated to the exclusion of the others, then making all the members strict can help GHC with little loss in flexibility.
u/tomejaguarin r/haskell • Mentions
On “Laziness in Haskell, Part 4: Thunks”
> Looking at the STG, it seems that the `if ...` expression is thunked, but the `x - 1` computation is not.
Ah nice, yes, thanks.
> It is inlined, though!
But there's a function right there in the Core called `$wsRgbToXyz` and there's a function called `sRgbToLuminance` that calls it. Am I missing something here?
u/tomejaguarin r/haskell • Mentions
On “Laziness in Haskell, Part 4: Thunks”
Ah yes, I think I was thinking of the next Core where `sRrgbToLuminance` does appear but it calls `$wsRgbToLuminace`, the wrapper, where `sRgbToXyz` has indeed been inlined. I think I was just looking at the wrong thing originally. Thanks!