SML to C!

sweeks@acm.org sweeks@acm.org
Mon, 13 Aug 2001 22:56:56 -0700


>> What's the difference in the performance in the case of the native and the
>> C-generated codes?
>
>You might want to ask on the MLton mailing list. I'd assume the performance
>should be comparable, but it definitely much faster to emit native code than
>to ask gcc to digest very larger C files. 

You are correct in that compile times are indeed much shorter with MLton's
native backend than with the C backend.  However, run time performance is also
much better with the native backend than with the C backend (and getting better
daily).  For some numbers, I took the latest MLton release (20010806) and ran it
on our suite of benchmarks (available off of the MLton performance page
http://www.sourcelight.com/MLton/performance.html), comparing the native and C
backends.  I computed the ratio of the run time of the benchmark compiled with
the C backend to the benchmark compiled with the native backend.  In 32 out of
of 36 benchmarks, the ratio was greater than one (i.e. the native backend is
doing better than the C backend).  Here are the numbers.

benchmark	       ratio
----------------       -----
barnes-hut              1.2
checksum                1.3
count-graphs            1.7
DLXSimulator            1.1
fft                     1.6
fib                     1.1
hamlet                  1.7
knuth-bendix            1.2
lexgen                  2.5
life                    1.9
logic                   1.2
mandelbrot              2.1
matrix-multiply         1.8
md5                     1.5
merge                   1.3
mlyacc                  1.4
mpuz                    2.2
nucleic                 1.1
peek                    2.2
psdes-random            0.9
ratio-regions           2.4
ray                     1.4
raytrace                1.5
simple                  1.7
smith-normal-form       1.0
tailfib                 0.9
tak                     1.5
tensor                  0.5
tsp                     1.4
vector-concat           2.7
vector-rev              3.3
vliw                    1.4
wc-input1               2.7
wc-scanStream           1.6
zebra                   1.8
zern                    1.8

Just for completeness, here are the compile times, in seconds, of the
benchmarks, compiled with both the native and C backends.  The native backend is
almost always faster, often significantly so.

benchmark         native      C
--------------	  ------    -----
barnes-hut          2.6       3.7
checksum            0.7       0.8
count-graphs        1.9       3.0
DLXSimulator        4.1       7.0
fft                 1.3       1.8
fib                 0.6       0.7
hamlet             54.2     130.0
knuth-bendix        2.5       5.1
lexgen              5.8      10.6
life                1.5       2.5
logic               7.6      20.3
mandelbrot          0.7       0.8
matrix-multiply     0.7       0.8
md5                 2.9       2.2
merge               0.7       0.8
mlyacc             20.3      40.1
mpuz                0.9       1.3
nucleic             4.0       4.6
peek                1.1       1.5
psdes-random        0.7       0.8
ratio-regions       2.7       3.9
ray                 3.4       6.0
raytrace           10.1      17.7
simple              6.8      14.6
smith-normal-form   7.8      68.4
tailfib             0.6       0.7
tak                 0.6       0.7
tensor              3.0       4.1
tsp                 1.7       2.4
vector-concat       0.7       0.8
vector-rev          0.7       0.8
vliw               12.8      25.3
wc-input1           1.7       2.7
wc-scanStream       1.8       2.9
zebra               5.1      14.5
zern                1.1       1.4