Skip to content

Draft: DmdAnal: Intern `Poly` and `nopDmdType` (#19190)

Sebastian Graf requested to merge wip/T19190 into master

In #19190 we discovered that a single build of Cabal allocated

  • Poly C_0N (aka topSubDmd) 150k times
  • DmdType emptyVarEnv [] topDiv (aka nopDmdType) 320k times

This patch interns all 6 variants of Poly and nopDmdType by using pattern synonyms that wrap a smart constructor.

Why not just use the smart constructor? Because

  • That way we can rename the old constructor (I suffixed with an underscore), so that all old use sites trivially refer to the new pattern synonym
  • We can be sure that all new use sites intuitively pick the new pattern synonym, simply because they are named the same as before. By constrast, a smart constructor needs continuous diligence and awareness to be called.

Fixes #19190.

Edited by Ben Gamari

Merge request reports