Opened 20 months ago

Last modified 12 months ago

#7190 new bug

GHC's -fprof-auto does not work with LINE pragmas

Reported by: timthelion Owned by:
Priority: normal Milestone: 7.8.3
Component: Profiling Version: 7.4.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

Please note the difference between the two .prof files created. The "profnopragma" one contains a "main" and the "profpragma" one doesn't. I came across this problem profiling a much larger source. In that case, ghc failed to profile anything within my source code at all!

[timothy@timothy haskell]$ cat profpragma.hs
f="hi"{-# LINE 1 "hi.hs" #-}
main :: IO (){-# LINE 2 "hi.hs" #-}
main = print f{-# LINE 3 "hi.hs" #-}
[timothy@timothy haskell]$ cat profnopragma.hs
f="hi"
main :: IO ()
main = print f
[timothy@timothy haskell]$ ghc profpragma.hs -prof -fprof-auto
[timothy@timothy haskell]$ ghc profnopragma.hs -prof -fprof-auto
[timothy@timothy haskell]$ ./profpragma +RTS -p
"hi"
[timothy@timothy haskell]$ ./profnopragma +RTS -p
"hi"
[timothy@timothy haskell]$ cat profpragma.prof 
	Sun Aug 26 20:30 2012 Time and Allocation Profiling Report  (Final)

	   profpragma +RTS -p -RTS

	total time  =        0.00 secs   (0 ticks @ 1000 us, 1 processor)
	total alloc =      49,704 bytes  (excludes profiling overheads)

COST CENTRE MODULE           %time %alloc

CAF         GHC.IO.Encoding    0.0    5.6
CAF         GHC.IO.Handle.FD   0.0   69.8
CAF         GHC.Conc.Signal    0.0    1.4
CAF         Main               0.0   21.7


                                                      individual     inherited
COST CENTRE MODULE                  no.     entries  %time %alloc   %time %alloc

MAIN        MAIN                     46           0    0.0    0.7     0.0  100.0
 CAF        Main                     91           0    0.0   21.7     0.0   22.1
  f         Main                     92           1    0.0    0.3     0.0    0.3
 CAF        GHC.Conc.Signal          87           0    0.0    1.4     0.0    1.4
 CAF        GHC.IO.Handle.FD         85           0    0.0   69.8     0.0   69.8
 CAF        GHC.IO.Encoding          80           0    0.0    5.6     0.0    5.6
 CAF        GHC.IO.Encoding.Iconv    66           0    0.0    0.5     0.0    0.5
[timothy@timothy haskell]$ cat profnopragma.prof 
	Sun Aug 26 20:30 2012 Time and Allocation Profiling Report  (Final)

	   profnopragma +RTS -p -RTS

	total time  =        0.00 secs   (0 ticks @ 1000 us, 1 processor)
	total alloc =      49,704 bytes  (excludes profiling overheads)

COST CENTRE MODULE           %time %alloc

CAF         GHC.IO.Encoding    0.0    5.6
CAF         GHC.IO.Handle.FD   0.0   69.8
CAF         GHC.Conc.Signal    0.0    1.4
main        Main               0.0   20.8


                                                      individual     inherited
COST CENTRE MODULE                  no.     entries  %time %alloc   %time %alloc

MAIN        MAIN                     46           0    0.0    0.7     0.0  100.0
 CAF        Main                     91           0    0.0    0.9     0.0   22.1
  f         Main                     93           1    0.0    0.3     0.0    0.3
  main      Main                     92           1    0.0   20.8     0.0   20.8
 CAF        GHC.Conc.Signal          87           0    0.0    1.4     0.0    1.4
 CAF        GHC.IO.Handle.FD         85           0    0.0   69.8     0.0   69.8
 CAF        GHC.IO.Encoding          80           0    0.0    5.6     0.0    5.6
 CAF        GHC.IO.Encoding.Iconv    66           0    0.0    0.5     0.0    0.5

Change History (1)

comment:1 Changed 12 months ago by igloo

  • Component changed from Compiler to Profiling
  • Difficulty set to Unknown
  • Milestone set to 7.8.1

Thanks for the report. We'll take a look.

Note: See TracTickets for help on using tickets.