[MLton-user] Tracking down allocations
Joe Hurd
joe at gilith.com
Fri Jul 20 05:00:07 PDT 2007
Hi Matthew,
Sorry for the delay in replying: I was at a conference at the
beginning of the week.
> I'd still be interested in seeing the source program, to see if there is a
> clear reason why the tuple is being eliminated in one version but not the
> other.
I've uploaded the two versions of the program to the TemporaryUpload
page of the MLton website, together with the results of profiling
allocations. There are two functions that produce different results
when manually lambda lifted: they can be found in the source by
searching for the string MLTON DEBUGGING.
Here are the sequence of commands I use to generate the allocation stats:
echo '$(SML_LIB)/basis/basis.mlb $(SML_LIB)/basis/mlton.mlb
lambda-lifted.sml' > lambda-lifted.mlb
mlton -runtime 'ram-slop 0.4' -verbose 1 -keep ssa -keep ssa2 -profile
alloc -profile-stack true -profile-branch true lambda-lifted.mlb
time ./lambda-lifted --time 100
mv mlmon.out lambda-lifted.out
mlprof -show-line true -raw true -keep '(and (thresh 0.1)
(thresh-stack 0.1))' -split '.*' lambda-lifted lambda-lifted.out >
lambda-lifted.txt
> Time profiling will include the time for the pattern match. If this
> function is called exactly once in the program, and accounts for 50% of
> the execution time, then I don't think the program is executing long
> enough to be meaningfully profiled.
Sorry, I wasn't clear enough. I meant that there is precisely one
location in the code where the function is called, not that the
function is called precisely once. The function is called millions of
times.
> Even so, it shouldn't be more than 24 instructions to discriminate (a
> comparision and conditional jump for each of the three variants, times
> four values to match).
That sounds very fast, but I suppose it could be the bottleneck. I did
slightly simplify the situation: the datatype is actually defined as
datatype class = Empty | Friend of int | Enemy of int;
In case you're interested, the big function definition is at line 9242
of lambda-lifted.sml, and the call site is at line 9550.
Thanks for your help,
Joe
More information about the MLton-user
mailing list