Fix quadratic behaviour in tidyOccName
authorSimon Peyton Jones <simonpj@microsoft.com>
Fri, 22 May 2015 13:46:51 +0000 (14:46 +0100)
committerSimon Peyton Jones <simonpj@microsoft.com>
Fri, 22 May 2015 14:05:25 +0000 (15:05 +0100)
commitc89bd681d34d3339771ebdde8aa468b1d9ab042b
tree0ea00d69f31a18cabd0ea0f6879d60dce952ae1c
parenteae703aa60f41fd232be5478e196b661839ec3de
Fix quadratic behaviour in tidyOccName

In the test program from comment:3 of Trac #10370, it turned out
that 25% of all compile time was going in OccName.tidyOccName!

It was all becuase the algorithm for finding an unused OccName
had a quadratic case.

This patch fixes it.  THe effect is pretty big:

Before:
total time  =       34.30 secs   (34295 ticks @ 1000 us, 1 processor)
total alloc = 15,496,011,168 bytes  (excludes profiling overheads)

After
total time  =       25.41 secs   (25415 ticks @ 1000 us, 1 processor)
total alloc = 11,812,744,816 bytes  (excludes profiling overheads)
compiler/basicTypes/OccName.hs
compiler/typecheck/TcMType.hs
compiler/types/TypeRep.hs
testsuite/tests/ghci.debugger/scripts/print027.stdout
testsuite/tests/parser/should_fail/T7848.stderr
testsuite/tests/simplCore/should_compile/T7360.stderr