#14564: CAF isn't floated
-------------------------------------+-------------------------------------
Reporter: neil.mayhew | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.2.2
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:
-------------------------------------+-------------------------------------
In the following code, `pattern` isn't floated, and the execution time is
20x slower than it should be:
{{{#!hs
import Text.Regex.TDFA (Regex, makeRegex, match)
main :: IO ()
main = do
entries <- map parseFilename . lines <$> getContents
let check (Right (_, t)) = last t == 'Z'
check _ = False
print $ all check entries
parseFilename :: String -> Either String (String, String)
parseFilename fn = case (pattern `match` fn :: [[String]]) of
[[_, full, _, time]] -> Right $ (full, time)
_ -> Left fn
where
pattern :: Regex
pattern = makeRegex
"^\\./duplicity-(full|inc|new)(-signatures)?\\.\
\([0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]T[0-9][0-9][0-9][0-9][0-9][0-9]Z)\\."
}}}
Curiously, it is floated when profiling is enabled, so the profiled
program ends up being 7x faster than the unprofiled one.
I can float the code manually (by taking out `where` and unindenting) and
the program then runs at an acceptable speed.
I get the same behaviour with 8.0.2, 8.2.1 and 8.2.2 but 7.10.3 is OK. I
don't think the OS and architecture makes a difference, but for the record
I'm on various flavours of 64-bit Linux.
Test input data is
[https://gist.github.com/neilmayhew/247a30738c0e294902e7c2830ca2c6f5 here]
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14564>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
#7206: Implement cheap build
-------------------------------------+-------------------------------------
Reporter: simonpj | Owner: simonpj
Type: bug | Status: new
Priority: normal | Milestone: ⊥
Component: Compiler | Version: 7.4.2
Resolution: | Keywords: FloatOut
Operating System: Unknown/Multiple | Architecture:
Type of failure: Runtime | Unknown/Multiple
performance bug | Test Case:
Blocked By: | Blocking:
Related Tickets: #8763, #13422 | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by simonpj):
Bottom line seems to be:
* Nofib results are no better, but no worse
* Some examples/tickets (which specifically?) really do improve.
Conclusion: let's do it. Ensuring that a Note gives a clear explanation,
and points to this ticket.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/7206#comment:27>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
#6087: Join points need strictness analysis
-------------------------------------+-------------------------------------
Reporter: simonpj | Owner: (none)
Type: bug | Status: infoneeded
Priority: normal | Milestone: 8.6.1
Component: Compiler | Version: 7.4.1
Resolution: | Keywords: JoinPoints
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 simonpj):
Correct. Another example might be
{{{
f :: Int -> [Int]
f 0 = []
f n = n : f (n-1)
}}}
It's strict all right, but we need the boxed 'n' for the result.
"Boxity" analysis might try to figure out when the boxed version is
needed, and pass that too. At one stage I had that but it seemed
unprincipled.
Bottom line so far: late demand analysis can be a win, but only rarely so;
and it can be a loss. It's a pity -- I'd like to make it part of -O2. But
we probably have higher priorities for now.
''Can you add the nofib numbers in a comment, please, for posterity?''
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/6087#comment:32>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
#7206: Implement cheap build
-------------------------------------+-------------------------------------
Reporter: simonpj | Owner: simonpj
Type: bug | Status: new
Priority: normal | Milestone: ⊥
Component: Compiler | Version: 7.4.2
Resolution: | Keywords: FloatOut
Operating System: Unknown/Multiple | Architecture:
Type of failure: Runtime | Unknown/Multiple
performance bug | Test Case:
Blocked By: | Blocking:
Related Tickets: #8763, #13422 | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by osa1):
I pushed my branch to `wip/cheap-build-osa1` in GHC's git repo as well.
Also attached the nofib output.
As to why `nums` is not inlined in comment:24, I see this in `-ddump-
inlinings` output:
{{{
Considering inlining: nums_aSY
arg infos []
interesting continuation RuleArgCtxt
some_benefit False
is exp: False
is work-free: False
guidance ALWAYS_IF(arity=0,unsat_ok=False,boring_ok=False)
ANSWER = NO
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/7206#comment:26>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
#6087: Join points need strictness analysis
-------------------------------------+-------------------------------------
Reporter: simonpj | Owner: (none)
Type: bug | Status: infoneeded
Priority: normal | Milestone: 8.6.1
Component: Compiler | Version: 7.4.1
Resolution: | Keywords: JoinPoints
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 osa1):
We decided to put this on hold at the meeting. Just a small update: the
case in comment:27 seems to be a limitation with the current demand
analyser. It sometimes introduces reboxing that can't be eliminated by the
simplifier. Example:
{{{
{-# NOINLINE check #-}
check :: Int -> Bool
check !n = True
f_ :: Int -> Int
f_ n = if check n then n else n * f_ (n - 1)
}}}
even after simplifications we rebox the argument:
{{{
Rec {
-- RHS size: {terms: 17, types: 3, coercions: 0, joins: 0/0}
$wf_
$wf_
= \ ww_s28U ->
case check (I# ww_s28U) of {
False ->
case $wf_ (-# ww_s28U 1#) of ww1_s28Y { __DEFAULT ->
*# ww_s28U ww1_s28Y
};
True -> ww_s28U
}
end Rec }
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/6087#comment:31>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler