[MLton-devel] cvs commit: source-level profiling

Stephen Weeks MLton@mlton.org
Fri, 3 Jan 2003 15:56:35 -0800

> 1. Why do source functions that appear in the final .ssa not appear
>     in the @MLton show-prof list?

The local stack inference that runs in profile.fun ignores certain
functions.  The relevant code is the shouldPush function.  I'm
guessing what you're seeing is due to the fact that shouldPush ignores
basis functions unless the local stack is empty.  I did this when
implementing -profile time -profile-stack false so that users would
see time in their code instead of basis library code.  It's probably
the right thing to do except for us when we need to work on the basis
library.  Also, it avoids getting lots of clock ticks in very simple
basis functions like Int.+.

For -profile stack true, it might make sense to change shouldPush to
track basis library functions too.  We need to experiment.

Anyways, you can cause everything to be tracked by having shouldPush
always return true.  With that, I think all source functions in the
final .ssa should make it into the @MLton show-prof list.

> 2. How does source mapping interact with pre-closure convert
>     simplifications?

Each source lambda comes in a pretty straightforward way from a source
line.  This source info stays with the lambda when it is duplicated
(for polymorphism or polyvariance) and dissappears when the lambda is

> Is it
>    true that if I were to eta expand, as in:
>       (* X.sml *)
>       structure X = struct
>                      structure X' = F(structure S = struct ... end)
>                      fun f n = X'.f n
>                      ...
>                     end
>    then I would see X:3 as a source function?

It depends on whether X.f gets inlined during (S)XML simplification.

>    Related, I don't understand why some "obvious" source level functions
>    never even make it to the first .ssa file.  

I suspect it's due to inlining.

I realize this behavior is annoying, and I have plans to (soon)
introduce the Enter/Leave statements in the XML so that they don't
disappear with inlining.  It shouldn't be too hard, but is not
entirely trivial, since I have to make sure that the Enter/Leaves
balance by the time we get to SSA.

This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
MLton-devel mailing list