Profiling trouble

Bayley, Alistair
Thu, 30 Jan 2003 16:33:31 -0000

> From: Ferenc Wagner []
> ...
> One more question: is there a way not to truncate the call
> stacks?  Ie in the hp file I see lines like
> (144)showData2/showData/ma...   12
> and I'd like to see showData2/showData/main or so.

hear, hear...

I'm also having some fun with profiling...

The GHC manual might want to mention that running ghc --show-iface
on an interface file won't work if it was compiled with -prof.
You get: "mismatched interface file versions: expected 5042, found 5042p"
Compiling sans -prof works.

Heap profiling falls over (seg fault) in some cases unless I compile with
Cost-centre profiling works in both cases, and reveals that without -O2, a
lot more heap is used:

Sans -O2:
	   queens +RTS -p -RTS

	total time  =       28.42 secs   (1421 ticks @ 20 ms)
	total alloc = 791,617,668 bytes  (excludes profiling overheads)

Avec -O2:
	   queens +RTS -p -hc -RTS

	total time  =       21.28 secs   (1064 ticks @ 20 ms)
	total alloc = 464,256,564 bytes  (excludes profiling overheads)

I suspect that using a lot of heap causes it to fall over.
(My program is called queens because I'm trying to solve
the Queens and Knights problem on this page:  )

How do I tell if my functions are strict or not?
The manual says:
"Look for your function in the interface file, then for the third field in
the pragma; it should say __S <string>. The <string> gives the strictness of
the function's arguments. L is lazy (bad), S and E are strict (good), P is
primitive (good), U(...) is strict and unpackable (very good), and A is
absent (very good)."

Now, my functions weren't exported, so I've exported some of them, and used
	ghc -Wall -ddump-simpl -ddump-hi ...
to compile, and now I get this (I've removed the Core syntax stuff, 'cos
there's a lot of it):

==================== NEW FINAL INTERFACE ====================
__interface "Main" Main 1 5042 where
__export  Main addQueens addQueens2 allSquares eightQueens keepBoard
knightsQueens main placeKnight placeQueen showBoard showBoards showRow
showSquare testAndAdd;
import Data.Set :: 1;
import GHC.IOBase :: 1;
import GHC.TopHandler :: 1;
import GHC.Base ! :: 1;
import GHC.Real :: 1;
import GHC.Enum :: 1;
import GHC.Num :: 1;
import GHC.Show :: 1;
import GHC.List :: 1;
import System.IO :: 1;
import Data.Tuple :: 1;
import GHC.Ptr :: 1;
import Foreign.Ptr ! :: 1;
import Data.FiniteMap :: 1;
(Main.$main) :: GHC.IOBase.IO ();
Main.knightsQueens :: [Main.Board];
Main.main :: GHC.IOBase.IO ();
Main.placeQueen :: Main.Board
		   -> [Main.Coord] -> [Main.Board] -> [Main.Board];
Main.placeKnight :: Main.Board
		    -> [Main.Coord] -> [Main.Board] -> [Main.Board];
Main.testAndAdd :: Main.Board -> [Main.Board] -> [Main.Board];
Main.keepBoard :: Main.Board -> GHC.Base.Bool;
Main.allSquares :: [Main.Coord];
Main.eightQueens :: [Main.Board];
Main.addQueens :: Main.Board
		  -> GHC.Base.Int -> [Main.Board] -> [Main.Board];
Main.addQueens2 :: Main.Board
		   -> GHC.Base.Int -> GHC.Base.Int -> [Main.Board] ->
Main.showBoards :: [Main.Board] -> GHC.Base.String;
Main.showBoard :: Main.Board -> GHC.Base.String;
Main.showRow :: Main.Board -> GHC.Base.Int -> GHC.Base.String;
Main.showSquare :: Main.Board
		   -> GHC.Base.Int -> GHC.Base.Int -> GHC.Base.Char;
type Main.Coord = (GHC.Base.Int, GHC.Base.Int);
type Main.Square = GHC.Base.Int;
type Main.Squares = Data.Set.Set Main.Square;
type Main.Board = (Main.Squares, Main.Squares, Main.Squares);

What should I be looking for? Can/should I inspect the Core syntax too?


The information in this email and in any attachments is 
confidential and intended solely for the attention and use 
of the named addressee(s). This information may be 
subject to legal professional or other privilege or may 
otherwise be protected by work product immunity or other 
legal rules.  It must not be disclosed to any person without 
our authority.

If you are not the intended recipient, or a person 
responsible for delivering it to the intended recipient, you 
are not authorised to and must not disclose, copy, 
distribute, or retain this message or any part of it.