[MLton] ref flattening

Daniel C. Wang danwang@CS.Princeton.EDU
Wed, 07 Jul 2004 16:00:27 -0400


Stephen,
Back a long time ago when I was hacking on the code for the programming 
language shootout. I turned a very ref heavy version of the statistical 
moments benchmark into a purely functional version. I was hoping to improve 
the performance by letting the compiler place record unboxed into the 
machine registers and avoid the overhead of refs. I remember getting a small 
enough improvement to submit the change.

Now with the ref flattening code. I'm wondering if it's better to go back to 
the old imperative looking version of statical moments that looks more like 
the ocaml code.

Here's the benchmark I'm referring too.

http://shootout.alioth.debian.org/lang/mlton/moments.mlton.html

Anyway, might be an interesting micro-benchmark to add to the current suite.
BTW perhaps we can convince the new benchmark maintainers to include an md5 
benchmark. :) That will really help show off mlton. I'm sure everyone is 
very pleased that mlton is second only to gcc right now with the default 
score card ranking. I'm sure an md5 benchmark will give mlton an edge.. and 
of course it is a realistic kind of thing to do. :)


Stephen Weeks wrote:

> I am pleased to report progress on the ref flattening optimization.  I
> have checked in code that now passes all the regressions and the
> benchmarks.   It does not yet self compile.  Here are the run time
> ratios for the benchmarks run "{-drop-pass refFlatten,}".  I've only
> included ratios that differ by more that 0.03 from 1.
> 
> MLton0 -- mlton -drop-pass refFlatten
> MLton1 -- mlton 
> 
> run time ratio
> benchmark         MLton1
> barnes-hut          0.84
> boyer               0.78
> fib                 0.94
> knuth-bendix        0.91
> lexgen              1.28
> logic               0.94
> matrix-multiply     1.05
> mlyacc              1.10
> mpuz                0.92
> nucleic             1.30
> output1             0.80
> ratio-regions       0.95
> tsp                 0.80
> 
>