Profiling trouble

Simon Marlow
Thu, 30 Jan 2003 18:10:14 -0000

> I'm also having some fun with profiling...
> First:
> 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,=20
> found 5042p"
> Compiling sans -prof works.

This bug has been fixed.

> Second:
> Heap profiling falls over (seg fault) in some cases unless I=20
> compile with -O2.

This is a bug - could you provide us with the source and instructions to

> Third:
> 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=20
> third field in
> the pragma; it should say __S <string>. The <string> gives=20
> the strictness of
> the function's arguments. L is lazy (bad), S and E are strict=20
> (good), P is
> primitive (good), U(...) is strict and unpackable (very=20
> good), and A is
> absent (very good)."

To see the pragmas, you need to compile the module with -O.  You can
view the interface with --show-iface.  For example, here's 'not' from
the Prelude:

1 not :: Bool
         -> Bool {-## __A 1 __C __S S __U (\ ds :: Bool -> case ds of
wild {False -> $wTrue; True -> $wFalse;}) ##-};

You can see that strictness pragma (following __S) is "S", which means
the function is strict in its single argument.