Byron / rust-tracer

A pet raytracer to see how fast rust can go
Other
15 stars 0 forks source link

title

Trace Quest 5: Rise of an Empire

Following cinematic success stories such as The SHA1 Performance Quest, there is yet another quest for performance, seeking out benchmark results that no man has seen before !

It's stardate 20.15.01.31, in a universe ruled by nimble Gophers and ancient Ceepeporg, a universe where the production of RaySpheres™ is the only goal, the faster, the better. Meet the Rustaceans, a young species, and follow them on their curious quest for independence and for producing the most RaySperes in the universe.

How to run

Generating images is as easy as running make in the respective source folder. We assume you have rust, go and gcc installed and in your PATH.

# rust
make image
# go
make -C src/go image
# c++
make -C src/cpp image

# Use more cores with go implementation to witness speedup
GOMAXPROCS=4 make src/go image
# Same with rust
RTRACEMAXPROCS=4 make image

Season 1 Conclusion

rtrace-image

Even though the rustacean RaySpheres are the prettiest thanks to an improved shading algorithm, on a single core we are not fastest. For some reason, C++ is 7 percent faster even though it is inefficient when creating the scene of more than 20.000 spheres and even though it uses virtual method calls.

Only when rust enters multi-threaded rendering mode, it is the fastest in town, as C++ doesn't implement multi-threading in this case.

Not to forget, go, which is far behind being about three times slower, no matter what.

Season 2 Preview

Things to do, in season two ...

Lessons Learned

Original Credits

The go based raytracer was originally written by Jack Palevich. For more information, see http://grammerjack.blogspot.com/2009/11/multi-threaded-go-raytracer.html.