Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add rust-vs-c benchmark #9

Merged
merged 3 commits into from
Nov 21, 2024
Merged

chore: add rust-vs-c benchmark #9

merged 3 commits into from
Nov 21, 2024

Conversation

thevilledev
Copy link
Owner

@thevilledev thevilledev commented Nov 21, 2024

Continues from N-R-K/ChibiHash#2 (comment)

Changes:

  • Add original C implementation to the repository
  • Add bench and build files to create similar test cases to run them in C and Rust
  • Create comparison report

The test cases here aim to test the following, to see if there's major compiler differences:

  • Memory access patterns (zeros, ones, alternating, incremental, random)
  • Alignment sensitivity: aligned/unaligned memory access
  • Size: variations for input data

@thevilledev thevilledev marked this pull request as ready for review November 21, 2024 19:21
@thevilledev
Copy link
Owner Author

Example results run on a M3 Pro (aarch64):

Screenshot 2024-11-21 at 21 18 09
Screenshot 2024-11-21 at 21 19 29

Based on this single test run smaller input sizes are faster on Rust. Questions:

  • Is it better because of Rust is better with stack-friendly allocations?
  • Is the memory layout more cache-friendly in Rust?
  • Does FFI add extra overhead to the C calls?
  • Rust monomorphisation?

Needs more tests and on different architectures.

@thevilledev thevilledev merged commit f036bc5 into main Nov 21, 2024
1 check passed
@thevilledev thevilledev deleted the chore/rust-vs-c branch November 21, 2024 19:29
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