[GHC] #14254: The Binary instance for TypeRep smells a bit expensive

GHC ghc-devs at haskell.org
Wed Oct 11 09:06:30 UTC 2017


#14254: The Binary instance for TypeRep smells a bit expensive
-------------------------------------+-------------------------------------
        Reporter:  dfeuer            |                Owner:  (none)
            Type:  bug               |               Status:  patch
        Priority:  normal            |            Milestone:  8.4.1
       Component:  Compiler          |              Version:  8.2.1
      Resolution:                    |             Keywords:  Typeable
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Compile-time      |  Unknown/Multiple
  performance bug                    |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):  Phab:D3998,
       Wiki Page:                    |  Phab:D4078, Phab:D4082
-------------------------------------+-------------------------------------

Comment (by dfeuer):

 The attached test case (`Big.hs`) takes a third of a second to run and
 allocates half a gigabyte of memory. I went through several iterations of
 solutions, yes. The three that strike me as significant contenders at the
 moment are:

 1. Phab:D4082, which is a pretty simple way to make sure deserialization
 is never too bad. This cuts total time to 0.029s and allocation to 17.7MB.

 2. Phab:D4085, which caches `TypeRep`s of kinds in each `TrTyCon` and
 `TrApp` constructor. This fixes the deserialization problem and also
 ensures that `Data.Dynamic.dynApply` is cheap. This has really been my
 preferred approach all along. There is some extra laziness I'd like to get
 rid of that is not entirely trivial to eliminate; bgamari may well know
 how to do so. This cuts total time to 0.023s and allocation to 15MB.

 3. Get rid of `typeRepKind`. This is definitely the most intrusive option,
 and I don't have a terribly clear sense of the consequences as yet, but
 I'm not sure we should dismiss it out of hand.

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14254#comment:11>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list