Path Tracing Three Ways: A Study of C++ Style
summary
Three versions of a toy path tracer are implemented and compared: object‑oriented, functional (C++ ranges, tl::optional) and data‑oriented, with source on GitHub and Compiler Explorer used for inspection. Benchmarks show the DoD build retires 150 billion instructions vs ~252B for OO/FP but suffers a 12% branch miss rate on triangle-heavy scenes (970 triangles), making it slower; a local fix using a bitwise-or trick to combine checks reduces misses and speeds the code ~36%. Tools: perf/stat and targeted microbenchmarks.
AI-written summary · about
chapters (8)
- 0:00Introduction and motivation
- 3:02Three C++ styles overview
- 11:24Object-oriented path tracing
- 23:13Functional programming approach
- 33:28Data-oriented design method
- 40:12Performance comparison results
- 43:21Debugging branch prediction issues
- 53:16Future directions and conclusions
related talks
51mTutorial: Performance Tools
55mHow to "OO" in C++
13mIntroducing PathProfiler – A Hardware Mechanism to Profile Dynamic Execution
40mLessons from two decades of writing bad code
51mKeynote: There Is No Silver Bullet to Solve All C++ Software Problems
56mWrite Fast Code Like a Native
56mIdentifying Common Code Smells
58mOO Considered Harmful
