[Haskell-cafe] Haskell version of ray tracer code is much slower
than the original ML
Philip Armstrong
phil at kantaka.co.uk
Thu Jun 21 06:55:04 EDT 2007
In odd spare moments, I took John Harrops simple ray tracer[1] & made a
Haskell version:
http://www.kantaka.co.uk/cgi-bin/darcsweb.cgi?r=ray
darcs get http://www.kantaka.co.uk/darcs/ray
It's pretty much a straight translation into idiomatic Haskell (as far
as my Haskell is idiomatic anyway).
Unfortunately, it's a lot slower than the ML version, despite turning
all the optimisation options up as far as they'll go. Profiling
suggests that much of the time is spent in the intersection' function,
and that the code is creating (and garbage collecting) an awful lot of
(-|) vector subtraction thunks. Trying to make intersection' or
ray_sphere stricter (with seq) appears to have no effect whatsoever:
the output of -ddump-simpl is unchanged (with the arguments all
staying lazy).
Am I missing anything obvious? I don't want to carry out herculean
code rewriting efforts: that wouldn't really be in the spirit of the
thing.
cheers, Phil
[1] http://www.ffconsultancy.com/languages/ray_tracer/comparison.html
--
http://www.kantaka.co.uk/ .oOo. public key: http://www.kantaka.co.uk/gpg.txt
More information about the Haskell-Cafe
mailing list