#3245: Quadratic slowdown in Data.Typeable
--------------------------------------+-------------------------------------
Reporter: guest | Owner: igloo
Type: merge | Status: new
Priority: normal | Milestone: 6.12 branch
Component: libraries (other) | Version: 6.10.1
Resolution: | Keywords:
Difficulty: Unknown | Os: Linux
Testcase: perf/should_run/T3245 | Architecture: x86
Failure: Runtime performance bug |
--------------------------------------+-------------------------------------
Changes (by simonpj):
* testcase: => perf/should_run/T3245
* owner: => igloo
* type: bug => merge
Comment:
Excellent point. Fixed by
{{{
Fri Dec 18 15:51:17 GMT 2009 [email protected]
* Fix Trac #3245: memoising typeOf
The performance bug in #3245 was caused by computing the typeRep
once for each call of typeOf, rather than once for each dictionary
contruction. (Computing TypeReps is reasonably expensive, because
of the hash-consing machinery.)
This is readily fixed by putting the TypeRep construction outside
the lambda. (Arguably GHC might have worked that out itself,
but it involves floating something between a type lambda and a
value lambda, which GHC doesn't currently do. If it happens a lot
we could fix that.)
M ./Data/Typeable.hs -29 +52
}}}
See `Note [Memoising typeOf]` in `Typeable.hs` which explains a bit more.
I added a regression test too.
I suppose we could merge this to the 6.12 branch, for the next patch
release.
Simon
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3245#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs