[MLton-user] MLton performance

Alan Morgan Alan Morgan <thefamouseccles@gmail.com>
Sun, 20 Mar 2005 11:51:21 -0800


On Sat, 12 Mar 2005 01:31:17 -0800, Stephen Weeks <sweeks@sweeks.com> wrote:
> 
> > Are you interested in cases where SML/NJ outperforms MLton?
> 
> Sure.

Gmail may have whacked me here.  Sorry if this is a double post.

I can't reproduce the original performance results with smaller
programs, but I did find something wierd which may explain the
disparity between SML and MLton.  This program:

fun maptest(s, n) =
    let
        val ll = List.tabulate (s, fn a => List.tabulate (s, fn b => b + a))
        val h = hd ll
        fun loop n =
            if n < 0 then
                ()
            else
                (map (fn c => ListPair.map op- (c, h)) ll;
                 loop (n-1))
    in
        loop n
    end

             
val _ = maptest(9, 5000000);   
 
 Runs in about 10 seconds on my (Dual Athlon, 512MB, Linux2.4) system.
 If I build it with the .mlb file:

$(SML_LIB)/basis/basis.mlb
test.sml

it's also about 10 seconds.  If I build it with:

$(SML_LIB)/basis/basis.mlb
$(SMLNJ_LIB)/Util/smlnj-lib.mlb
test.sml

the runtime drops to 15 seconds (I can get all sorts of different
results if I write my own versions of map and ListPair.map or
reimplement the MLton or SML/NJ ones with different names).  My
knowledge of x86 assembly language is pretty weak, so I'm pretty much
out of ideas.

Alan