[GHC] #14337: typeRepKind can perform substantial amounts of allocation
GHC
ghc-devs at haskell.org
Mon Oct 9 23:23:34 UTC 2017
#14337: typeRepKind can perform substantial amounts of allocation
-------------------------------------+-------------------------------------
Reporter: dfeuer | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone: 8.4.1
Component: Core | Version: 8.2.1
Libraries |
Keywords: Typeable | Operating System: Unknown/Multiple
Architecture: | Type of failure: Runtime
Unknown/Multiple | performance bug
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
I came up with a (rather contrived) test case to demonstrate that
Phab:D4082 reduced big-O time complexity in pathological cases. But I
expected it to increase space usage by a constant factor. What I found was
very much the opposite: it dramatically reduced allocation. The reason for
this is obvious in hindsight. Every time we call `typeRepKind`, we
recalculate the kind entirely from scratch. That recalculation is only a
potential ''time'' problem for `TrApp`, because we only need to walk down
links, but it's also a ''space'' problem for `TrTyCon`, because we're
building up a `TypeRep` from a `KindRep`.
The solution, assuming we choose to keep `typeRepKind`, seems fairly
clear: whether or not we choose to cache the kind in `TrApp`, we should
almost certainly do so in `TrTyCon`.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14337>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list