tracer

Crates.iotracer
lib.rstracer
version0.1.0
sourcesrc
created_at2015-02-11 07:44:25.224771
updated_at2015-12-11 23:59:11.698689
descriptionA pet raytracer to test overall pseudo-performance and multi-threading
homepage
repositoryhttps://github.com/Byron/rust-tracer
max_upload_size
id1379
size49,005
Sebastian Thiel (Byron)

documentation

README

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

Make sure you have gcc installed as well as go for the respective version. Then it's the following to produce images and time them. Please note that they will only use one core by default - the cpp version doesn't impelement multi-threading.

make -C src/go image
make -C src/cpp image

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

Lessons Learned

  • Instead of parameterizing primitive number types in generics, use a type alias instead. That way, the code is simpler overall, and you may use number literals in your code. This is viable if you just want to test how different number types will affect your runtime performance.
  • When using multi-threading, everything used by a thread needs to have static lifetime. To assure that, you can
    • create resources within the thread, handle them and send a particular result through a channel.
    • pass in read-only shared resources through an Arc. The latter is a reference counted item on the heap.
    • pass writable resources through an Arc<Mutex<R>> to allow synchronized access.
    • Yes, it's not currently possible to signal a resource is safe for use if allocated on a stack and protected by guards that will assure the resource remains alive during the thread runtime.

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.

Commit count: 69

cargo fmt