[GHC] #11735: Optimize coercionKind
GHC
ghc-devs at haskell.org
Tue Jan 30 14:27:18 UTC 2018
#11735: Optimize coercionKind
-------------------------------------+-------------------------------------
Reporter: goldfire | Owner: (none)
Type: task | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.10.3
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Compile-time | Unknown/Multiple
performance bug | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by goldfire):
I think I see what's going on here. The "cached role" results are from
commit 8ac966971ec6c30cc3681a913fb9fb1c2342f6cc. This version eagerly
computes the role for an `NthCo` in `mkNthCo`. This means that every
(`seq`ed) `NthCo` requires a role calculation. Perhaps sometimes, we
create an `NthCo` and never ever check its role. If that's the case, then
8ac96 will be worse.
On the other hand, what if you try my commit
8a6aa5030d34592200fbe799bf38abf3701544db? (Do not be thrown off by the
same first two characters of the hash! I was.) That commit supplies the
role to `mkNthCo`, as it can often be deduced by the caller of `mkNthCo`
without too much trouble. No redundant role computation. This one should
really be a clear win.
By the way, I changed slightly the way I cached the role: I allowed a more
permissive role in the `NthCo`. For example, suppose you have `g :: [a] ~N
[b]` and you want `h :: a ~R b`. Before these patches, you would use `h =
SubCo (NthCo 0 g)`. With the patch, you can now say `h = NthCo
Representational 0 g`, where Lint checks to make sure that the role is
appropriate. Because of this new degree of freedom, it became necessary to
serialize the role in iface files. (The serializer could instead be clever
and convert an `NthCo` into a `SubCo` and an `NthCo`, but that seemed not
to be worth it.) I forget if this realization about iface files made it
into the original patch -- that change might be in a later commit. But the
commit I referenced above should work fine outside of iface files.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11735#comment:60>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list