Severing ties: the need for non-updateable thunks
summary
Lazy thunk updates create long in-memory instruction chains and trigger expensive major GCs; duplicating thunks before pattern-matching severs those links so each evaluated copy can be collected by minor GC. The practical workaround is the dupIO package which provides non-updateable thunks via shallow copies (no deep-graph copy), is tested on GHC 8.6–9.6, removes the linked-list leak (the demo shows a 1.6 GB pipe buildup without duplication), and works but remains a low-level, hacky solution rather than a language-level fix.
AI-written summary · about
chapters (9)
- 0:00Introduction to the problem
- 1:03DSL memory leak explained
- 2:29The thunk duplication solution
- 6:20Complexities of manual copying
- 9:45GHC optimization pitfalls
- 12:34Risks of unsafe operations
- 14:00GC promotion and heap growth
- 19:19Current tools and future ideas
- 22:09Q&A and concluding remarks
related talks
50mTemplate Haskell, a case study in (in)stability
55mDeforestation and Program Fusion
01h 09mWhy Functional Programming with Linear Types Matters
53mVariables in Haskell
01h 04mHaskell - A Peek Inside the Ivory Tower
01h 38mGHC Core Optimisations
01h 04mNot-So-Boring Haskell
44mRevisiting pattern match overlap checks in Haskell
