[GHC] #11688: Bytestring break failing rewrite to breakByte and failing to eliminate boxing/unboxing

GHC ghc-devs at haskell.org
Thu Mar 24 15:12:32 UTC 2016


#11688: Bytestring break failing rewrite to breakByte and failing to eliminate
boxing/unboxing
-------------------------------------+-------------------------------------
        Reporter:  alexbiehl         |                Owner:
            Type:  bug               |               Status:  patch
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  7.10.3
      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):  Phab:D1980
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by Ben Gamari <ben@…>):

 In [changeset:"0bd0c31e833055eb3e86177f70c4b4d93d5a1c11/ghc"
 0bd0c31e/ghc]:
 {{{
 #!CommitTicketReference repository="ghc"
 revision="0bd0c31e833055eb3e86177f70c4b4d93d5a1c11"
 Defer inlining of Eq for primitive types

 Summary:
 This is one solution to #11688, wherein (==) was inlined to soon
 defeating a rewrite rule provided by bytestring. Since the RHSs of Eq's
 methods are simple, there is little to be gained and much to be lost by
 inlining them early.

 For instance, the bytestring library provides,

 ```lang=haskell
 break :: (Word8 -> Bool) -> ByteString -> (ByteString, ByteString)
 breakByte :: Word8 -> ByteString -> (ByteString, ByteString)
 ```

 and a rule

 ```
 forall x. break ((==) x) = breakByte x
 ```

 since `breakByte` implments an optimized version of `break (== x)` for
 known `x :: Word8`. If we allow `(==)` to be inlined too early, we will
 prevent this rule from firing. This was the cause of #11688.

 This patch just defers the `Eq` methods, although it's likely worthwhile
 giving `Ord` this same treatment. This regresses compiler allocations
 for T9661 by about 8% due to the additional inlining that we now require
 the simplifier to perform.

 Updates the `bytestring` submodule to include updated rewrite rules
 which match on `eqWord8` instead of `(==)`.

 Test Plan:
  * Validate, examine performance impact

 Reviewers: simonpj, hvr, austin

 Subscribers: thomie

 Differential Revision: https://phabricator.haskell.org/D1980

 GHC Trac Issues: #11688
 }}}

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


More information about the ghc-tickets mailing list