Skip to content

Ray tracer benchmark: memory models vs Rust - #634

Merged
ASDAlexander77 merged 3 commits into
mainfrom
benchmark-raytrace-vs-rust
Oct 21, 2026
Merged

ASDAlexander77 merged 3 commits into
mainfrom
benchmark-raytrace-vs-rust

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

Adds tslang/benchmarks/raytrace/, a rerunnable comparison of the raytrace.ts test under each memory model against two Rust ports of the same algorithm.

  • rtbench.ts: test/tester/tests/raytrace.ts at 512x512, summing every pixel into a checksum (38837369) so the render cannot be optimized away and all builds can be compared.
  • rust/src/bin/idiomatic.rs: Copy vectors/colors, Box<dyn Thing>.
  • rust/src/bin/boxed.rs: every Vector/Color/Ray/Intersection in an Rc, roughly tslang's allocation pattern.
  • bench.ps1: builds gc/rc/none/own (with and without stack promotion) and both Rust ports, checks the checksum, times each binary.

Results 2026-10-21 (median of 7): gc 1276 ms, rc 624 ms, none 690 ms (845 MB peak), own does not compile; Rust idiomatic 56 ms, Rust Rc-boxed 504 ms. Stack promotion has no measurable effect: its report keeps every hot-path allocation on the heap. Details in the README.

Test plan: ran pwsh tslang/benchmarks/raytrace/bench.ps1 -Runs 3 from the branch; every build prints the same checksum. No compiler or test-suite changes.

🤖 Generated with Claude Code

ASDAlexander77 and others added 3 commits October 21, 2026 21:58
tslang/benchmarks/raytrace holds the raytrace.ts test at 512x512 with a
pixel checksum, an idiomatic Rust port, a Rust port that heap-allocates
every object through Rc, and bench.ps1, which builds them all, checks the
checksum and times them. README records the 2026-10-21 results.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cpp/idiomatic.cpp (value structs, unique_ptr things) and cpp/shared.cpp
(every object a make_shared, std::function surfaces), built by bench.ps1
with clang++ -O3 and MSVC /O2. Both READMEs carry the new numbers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit 35ac7ff into main Oct 21, 2026
2 checks passed
@ASDAlexander77
ASDAlexander77 deleted the benchmark-raytrace-vs-rust branch October 21, 2026 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant