Skip to content

Quadratic constructor tag allocation

With a large data type like:

data A = A0
  | A0001
  | A0002
...
  | A9999

GHC spends a lot of time allocating constructor tags. It accounts for half of allocations for large data types like this.

The hot piece of code is in mkDataCon:

   tag = assoc "mkDataCon" (tyConDataCons rep_tycon `zip` [fIRST_TAG..]) con

Previous discussion: https://mail.haskell.org/pipermail/ghc-devs/2017-October/014974.html

Trac metadata
Trac field Value
Version
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information