[GHC] #7753: Profiling report broken with foreign exported functions
GHC
cvs-ghc at haskell.org
Fri Mar 8 06:46:24 CET 2013
#7753: Profiling report broken with foreign exported functions
-------------------------+--------------------------------------------------
Reporter: akio | Owner:
Type: bug | Status: new
Priority: normal | Component: Profiling
Version: 7.6.2 | Keywords:
Os: Linux | Architecture: Unknown/Multiple
Failure: None/Unknown | Blockedby:
Blocking: | Related:
-------------------------+--------------------------------------------------
Save the following Haskell source as wrapper.hs:
{{{
import Foreign.Ptr
import Control.Monad
main = do
fptr <- wrap wrapped
replicateM 100 $ (return$!) =<< dyn fptr 4
wrapped :: Double -> IO Double
wrapped x = return $ f 10000 x
f :: Int -> Double -> Double
f 0 u = u
f n u = (u / fromIntegral n) * f (n-1) u
foreign import ccall "wrapper" wrap :: (Double -> IO Double) -> IO (FunPtr
(Double -> IO Double))
foreign import ccall "dynamic" dyn :: FunPtr (Double -> IO Double) ->
Double -> IO Double
}}}
Then compile and run it with:
{{{
$ ghc -O2 wrapper.hs -fprof-auto -prof
$ ./wrapper +RTS -p
}}}
It generates wrapper.prof (attached). The file contains the following
lines:
{{{
CAF GHC.IO.Encoding.Iconv 58 0 0.0 0.2 0.0
0.2
wrapped Main 80 100 0.0 1.1 0.0
0.0
f Main 81 1000100 100.0 0.0 0.0
0.0
}}}
I see two problems here, (1) the inherited column is 0 for 'wrapped' and
'f' but this is incorrect, and (2) 'wrapped' and 'f' belongs to the wrong
cost center, 'GHC.IO.Encoding.Iconv'.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7753>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list