#7429: Unexplained performance boost with +RTS -h
---------------------------------+------------------------------------------
Reporter: simonmar | Owner:
Type: bug | Status: new
Priority: normal | Milestone: 7.8.1
Component: Compiler | Version: 7.6.1
Keywords: | Os: Unknown/Multiple
Architecture: Unknown/Multiple | Failure: Runtime performance bug
Difficulty: Unknown | Testcase:
Blockedby: | Blocking:
Related: |
---------------------------------+------------------------------------------
Comment(by tomberek):
Some code golf at #haskell produced a new version of iterateM:
{{{
iterateM2 :: Monad m => Int -> (b -> m b) -> b -> m b
iterateM2 = (fmap.fmap) (foldr (>=>) return) replicate
}}}
This produces slightly different CORE as follows:
Rec {
Main.main6 [Occ=LoopBreaker]
:: forall s_atH.
GHC.Prim.Int#
-> Main.CircList s_atH
-> GHC.Types.Int
-> GHC.Prim.State# s_atH
-> (# GHC.Prim.State# s_atH,
(Main.CircList s_atH, GHC.Types.Int) #)
[GblId, Arity=4, Caf=NoCafRefs, Str=DmdType LSLL]
Main.main6 =
\ (@ s_atH)
(m_a16D :: GHC.Prim.Int#)
(eta_B3 :: Main.CircList s_atH)
(eta1_X14 :: GHC.Types.Int)
(eta2_X15 :: GHC.Prim.State# s_atH) ->
case GHC.Prim.<=# m_a16D 1 of _ {
GHC.Types.False ->
case eta_B3 of _ { Main.ConsM rb_dE3 rb1_dE4 ->
case GHC.Prim.readMutVar#
@ s_atH @ (Main.CircList s_atH) rb1_dE4 eta2_X15
of _ { (# ipv_aEY, ipv1_aEZ #) ->
Main.main6 @ s_atH (GHC.Prim.-# m_a16D 1) ipv1_aEZ eta1_X14
ipv_aEY
}
};
GHC.Types.True ->
case eta_B3 of _ { Main.ConsM rb_dE3 rb1_dE4 ->
case GHC.Prim.readMutVar#
@ s_atH @ (Main.CircList s_atH) rb1_dE4 eta2_X15
of _ { (# ipv_aEY, ipv1_aEZ #) ->
(# ipv_aEY, (ipv1_aEZ, eta1_X14) #)
}
}
}
end Rec }
This destroys the effect, ie: it only produces the "slow" version. The
iterateM as is, WITH StateT over ST WITH (+RTS -s -h) is the only way I
have been able to produce the "fast" version.
And to clarify the effect:
1) I compile with -O2 -rtsopts.
2) I run with +RTS -s
3) Without recompiling or anything else I run +RTS -s -h
#3 is faster than #2 or ANYTHING else, including no RTS, no -rtsopts.
It still works with -O1
I end up thrashing the system when I compile without an -Ox flag
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7429#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs