[Shootout-list] Ray tracer

Stephen Weeks sweeks@sweeks.com
Fri, 17 Jun 2005 05:45:45 -0700


> For the record, our site now contains several different versions of
> the raytracers in different languages:
> 
>   http://www.ffconsultancy.com/free/ray_tracer/languages.html
> 
> In particular, there are C++, OCaml and MLton versions which are
> more than twice as fast as those on the shootout.

I looked into the MLton raytracer to see what's going on.  To be
clear, I looked at revision 1.3 of raytracer.mlton-2.mlton in the
shootout CVS, which is roughly the same as

  http://www.ffconsultancy.com/free/ray_tracer/code/4/ray.sml

I compared this to revision 1.2 of raytracer.mlton-2.mlton in the
shootout CVS.  I see a 2.5 speedup in raytracer.mlton-2 over
raytracer.mlton.  The speedup is partially due to algorithmic
improvements (better bounding and intersection) and partially due to
different ordering of the subscenes in the create function.  I believe
all of these improvements fall outside the kinds of differences among
implementations that are generally allowed in the shootout.

The subscene ordering problem was already mentioned by Oleg Trott on
comp.lang.functional.  As an example, reversing the subscene ordering
in raytracer.mlton-2 slows it down by about 50%.

It would be nice for the algorithm and problem spec to be clarified
and to stabilize, because I would guess a lot of implementations are
out of sync, so it's not very clear what is being compared.

In any case, I've committed a new revision of raytracer.mlton that
makes the same algorithmic improvements as in raytracer.mlton-2.  They
now run at roughly the same speed.