Opened 4 years ago

Last modified 3 months ago

#7190 new bug

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

Reported by: timthelion Owned by:
Priority: normal Milestone:
Component: Test Suite Version: 7.4.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

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 (8)

comment:1 Changed 3 years 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.

comment:2 Changed 2 years ago by thoughtpolice

  • Milestone changed from 7.8.3 to 7.10.1

Moving to 7.10.1

comment:3 Changed 21 months ago by thomie

This seems to be fixed in or before the 7.8.1 release. The profiling report for profpragma.hs now does have an entry for the function main.

A regression test should be added, then this ticket can be closed.

Last edited 21 months ago by thomie (previous) (diff)

comment:4 Changed 20 months ago by thoughtpolice

  • Milestone changed from 7.10.1 to 7.12.1

Moving to 7.12.1 milestone; if you feel this is an error and should be addressed sooner, please move it back to the 7.10.1 milestone.

comment:5 Changed 12 months ago by thoughtpolice

  • Milestone changed from 7.12.1 to 8.0.1

Milestone renamed

comment:6 Changed 11 months ago by thomie

  • Component changed from Profiling to Test Suite

Bug is fixed. Just needs a test.

comment:7 Changed 7 months ago by thomie

  • Milestone 8.0.1 deleted

comment:8 Changed 3 months ago by osa1

I'm going over cost-center-related tickets -- does anyone know how do I test and close this? As far as I can see .prof.sample files are not good enough for testing purposes. For example, I created a .prof.sample for testing this, but if I remove a random line in that file the test is still accepted. What am I doing wrong?

Note: See TracTickets for help on using tickets.