[GHC] #12665: Make Read instances faster, and make them fail fast

GHC ghc-devs at haskell.org
Fri Oct 7 18:27:39 UTC 2016


#12665: Make Read instances faster, and make them fail fast
-------------------------------------+-------------------------------------
        Reporter:  dfeuer            |                Owner:  dfeuer
            Type:  feature request   |               Status:  new
        Priority:  high              |            Milestone:  8.2.1
       Component:  Core Libraries    |              Version:  8.0.1
      Resolution:                    |             Keywords:
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:                    |
-------------------------------------+-------------------------------------

Comment (by int-e):

 Replying to [comment:11 dfeuer]:
 > There's an unfortunate problem with the memoized base list. [...]

 One can also store the bases in the stack itself, see `valInteger''` in
 the (updated) http://int-e.eu/~bf3/haskell/FromDigits.hs file. This causes
 some extra allocations, so the code becomes slower, but almost
 imperceptibly so.

 In my crude measurements (code compiled with -O2, run by using the `test*`
 functions in `ghci`), converting a list of 10,000,000 digits in base 10
 takes 8.1s with the code currently in base (`Data.Read.Lex.valInteger`),
 2.0s with `valInteger'` and 2.1s with `valInteger''`.

 Converting 2^18^ 18 digit integers takes 0.47s with the original code,
 0.23s with `valInteger'` and `valInteger''`.

 Note that no actual lexing is done by this code.

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


More information about the ghc-tickets mailing list