Repository navigation
Ray tracer benchmark: memory models vs Rust - #634
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
tslang/benchmarks/raytrace/, a rerunnable comparison of theraytrace.tstest under each memory model against two Rust ports of the same algorithm.rtbench.ts:test/tester/tests/raytrace.tsat 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:Copyvectors/colors,Box<dyn Thing>.rust/src/bin/boxed.rs: everyVector/Color/Ray/Intersectionin anRc, 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 3from the branch; every build prints the same checksum. No compiler or test-suite changes.🤖 Generated with Claude Code