Skip to content

Fix handling ze_meta_tv_env in GHC.Tc.Utils.Zonk

Simon Peyton Jones requested to merge wip/T19668 into master

As #19668 (closed) showed, there was an /asymptotic/ slow-down in zonking in GHC 9.0, exposed in test T9198. The bug was actually present in earlier compilers, but by a fluke didn't actually show up in any of our tests; but adding Quick Look exposed it.

The bug was that in zonkTyVarOcc we

  1. read the meta-tyvar-env variable
  2. looked up the variable in the env
  3. found a 'miss'
  4. looked in the variable, found Indirect ty
  5. zonked ty
  6. update the env gotten from step 1 to map the variable to its zonked type.

The bug is that we thereby threw away all the work done in step 4. In T9198 that made an enormous, indeed asymptotic difference.

The fix is easy: use updTcRef.

I commented in Note [Sharing when zonking to Type]

Merge request reports