Heap profiling with ghc and hp2ps and strict function application ($!) gives samples out of sequence (regression)
The following program generates an invalid .hp file when compiled with ghc 8.2.1 but it does not when using ghc 8.0.2.
{-# LANGUAGE ScopedTypeVariables #-}
module Main where
eval :: forall a b. (a -> b -> b) -> b -> [a] -> b
eval f b xs = load xs []
where
load :: [a] -> [a] -> b
load [] stk = unload b stk
load (x:xs) stk = load xs (x : stk)
unload :: b -> [a] -> b
unload v [] = v
unload v (x : stk) = unload ((f $! x) $! v) stk
main :: IO ()
main = print (eval (||) False (True : replicate 10000000 False))
If strict application (!) is substituted for normal application (
) or removed then the .hp generated file is correct.
For reproducing the error:
ghc -O2 --make -prof -fprof-auto Example.hs -fforce-recomp
./Example +RTS -hc
hp2ps -e8in -c Example.hp
It outputs:
hp2ps: Example.hp, line 43, samples out of sequence
Trac metadata
Trac field | Value |
---|---|
Version | 8.2.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Runtime System |
Test case | |
Differential revisions | |
BlockedBy | |
Related | #14006 (closed) |
Blocking | |
CC | |
Operating system | |
Architecture |