[GHC] #2393: Text.PrettyPrint.HughesPJ: Bug fixes, performance improvement

GHC ghc-devs at haskell.org
Wed Aug 12 14:21:03 UTC 2015


#2393: Text.PrettyPrint.HughesPJ: Bug fixes, performance improvement
-------------------------------------+---------------------------------
        Reporter:  guest             |         Owner:
            Type:  bug               |        Status:  closed
        Priority:  normal            |     Milestone:  6.10.1
       Component:  libraries/pretty  |       Version:  6.8.3
      Resolution:  fixed             |      Keywords:
Operating System:  Unknown/Multiple  |  Architecture:  Unknown/Multiple
       Test Case:                    |
-------------------------------------+---------------------------------

Comment (by Thomas Miedema <thomasmiedema@…>):

 In [changeset:"f903949beee3a4e0a925003b5553066c9f513c11/ghc" f903949/ghc]:
 {{{
 #!CommitTicketReference repository="ghc"
 revision="f903949beee3a4e0a925003b5553066c9f513c11"
 Pretty: improving the space/time performance of vcat, hsep, hcat (#10735)

 After 5d57087e314bd484dbe14958f9b422be3ac6641a ("Pretty: fix a broken
 invariant"), T3294 showed 50% more max_bytes_used (#3294). After this
 commit, max_bytes_used is back to what it was before, and the test
 passes again.

 This is a backport of a bug fix by Benedikt Huber (#2393), from commit
 1e50748beaa4bd2281d323b18ea51c786bba04a1 in the pretty library.

 From https://mail.haskell.org/pipermail/libraries/2008-June/009991.html:

     vcat (hsep,cat) is implemented in an unneccessarily strict way.
     We only get some output after all of vcat's arguments are evaluated
     and checked against being Empty.
     This can be improved by only checking the right argument of foldr
     against being Empty, and
     then applying an Empty-filter on the resulting Doc. Space improvement
     is obvious.
     The microbenchmark (code.haskell.org/~bhuber/Text/PrettyPrint/
     HughesPJPerfCheck.hs) suggests that
     the improvements in time are remarkable too.
 }}}

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


More information about the ghc-tickets mailing list