[GHC] #8900: unordered-containers 16% slower in HEAD vs 7.6.3

GHC ghc-devs at haskell.org
Sat Mar 15 21:07:09 UTC 2014


#8900: unordered-containers 16% slower in HEAD vs 7.6.3
--------------------------------------------+------------------------------
        Reporter:  tibbe                    |            Owner:
            Type:  bug                      |           Status:  new
        Priority:  normal                   |        Milestone:
       Component:  Compiler                 |          Version:  7.9
      Resolution:                           |         Keywords:
Operating System:  MacOS X                  |     Architecture:  x86_64
 Type of failure:  Runtime performance bug  |  (amd64)
       Test Case:                           |       Difficulty:  Unknown
        Blocking:                           |       Blocked By:
                                            |  Related Tickets:
--------------------------------------------+------------------------------

Comment (by tibbe):

 I've found a likely culprit in the generated Core.

 Compare the case for `Full` in `$wpoly_go` for
 [https://ghc.haskell.org/trac/ghc/attachment/ticket/8900/HashMapInsert-7.6.3
 .dump-simpl#L569 7.6.3]:

 {{{
 569             case indexArray# rb_a1cI i#_s1oq of _ { (# ipv2_a1cS #) ->
 570             case $wpoly_go ww_s2HT ww1_s2HX w_s2HZ (+# ww2_s2I2 4)
 ipv2_a1cS
 571             of st'_a1cV { __DEFAULT ->
 }}}

 vs the case for `Full` in `$wpoly_go` for
 [https://ghc.haskell.org/trac/ghc/attachment/ticket/8900/HashMapInsert-
 HEAD.dump-simpl#L554 HEAD]:

 {{{
 554             case indexArray# dt_a2Ly i#_a2LH
 555             of _ [Occ=Dead] { (# ipv2_a2LM #) ->
 556             case ipv2_a2LM of st_a2LO { __DEFAULT ->
 557             case $wpoly_go ww_s4A3 ww1_s4A7 w_s4zY (+# ww2_s4Ab 4)
 st_a2LO
 558             of st'_a2LP { __DEFAULT ->
 }}}

 Both cases correspond to this snippet in `Data.HashMap.Base`:

 {{{
 #!haskell
     go h k x s t@(Full ary) =
         let !st  = A.index ary i
             !st' = go h k x (s+bitsPerSubkey) st
 }}}

 Here's the definition for `A.index`:

 {{{
 #!haskell
 index :: Array a -> Int -> a
 index ary _i@(I# i#) =
         case indexArray# (unArray ary) i# of (# b #) -> b
 }}}

 There's an extra `case` in the HEAD version, which translates into an
 extra tag bits check in the Cmm. This happens in a couple of places in the
 core. This `case` is unnecessary since `$wpoly_go` scrutinizes `st_a2LO`
 immediately. This looks like a regression in strictness analysis.

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


More information about the ghc-tickets mailing list