[MLton-devel] Porting from Moscow ML
Sat, 28 Sep 2002 17:50:28 -0700
> In fact, the main reason for porting to MLton was to make use of the
> profiling facilities, but I was rather disappointed with the results:
> I hardly recognized any of the functions in my program in the
> yellow/red areas of the call graph.
I tried out mlprof on your program as follows:
% mlton -keep dot -profile true z.sml
% ./z >/dev/null
% mlprof -t 1 -color -s z mlmon.out
53.75 seconds of CPU time
forward (C @ 0x80CC300) 7.81%
isAligned (C @ 0x80C7260) 4.84%
cheneyCopy (C @ 0x80C8380) 3.72%
String_equal (C) 2.60%
All the (C @ 0x???) stuff is GC. The top most used function is f_0.
To figure out what that is, have a look at the SSA code for fun f_0 in
z.ssa and at the SSA control-flow graph for f_0.
% /usr/bin/dot -Tps z.f_0.cfg.dot >f_0.ps
% gv f_0.ps &
Looking at that, I see that the first thing f_0 does is a case on its
only argument to see whether it is variant Fn or variant Var. Looking
through your source code, there is only one such f function, in
tm_subst. Looking further in the control-flow graph, you can see that
find_unchanged and list_unchanged have been inlined inside f. You can
also try the -d 1 option to mlprof to see the hot basic blocks inside
f_0. Again, with -color it will color the SSA control-flow graph.
Anyways, I hope that gives you the idea. I'm afraid that's the best
we have for now -- look at the SSA code and the corresponding
control-flow graph, and look for the matching code in the SML source.
All of the x_???? functions are anonymous lambdas in the source.
These often arise from curried functions. For example, x_5914 appears
to be tree_foldr (which is curried). In particular it appears to be
the use in TermNet1.to_list. I see lots of flattens and maps there.
Those can often be deforested and optimized.
Hope this helps. Please feel free to ask questions about the SSA
IL and dot graphs, since those aren't too well documented.
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
MLton-devel mailing list