-
Notifications
You must be signed in to change notification settings - Fork 107
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
Suggestion: align fib() function to DSB boundary (64 byte) #129
Comments
Hi @Kogia-sima interesting stuff! The original goal was to show speed differences between Crystal and Ruby, but it's since grown to include more than just the top 10 languages. I will look closer into the code alignment issue. Someone mentioned it before but didn't have a suggestion on how to address it. I think there are other issues with this benchmark when trying to compare languages like C vs Rust and I probably should add a disclaimer. |
Even though another factor also affects the performance, I bet the code alignment is dominant here. For example, I see that Rust 1.42.0 and 1.50.0 produces different results for 16-byte alignment, but almost same results for 64-bytes alignment. In the case of Rust, there is actually one more factor that affects performance: LLVM inserts nop before loops to avoid alignment issue on some processors. With this padding
I understood your goals, so the best solution would be to add proper disclaimer to readme. |
Here is another experiments to prove that 64 bytes alignment produces consistent results.
|
It seems that some benchmarks for statically compiled languages (C, Rust, Fortran etc.) heavily depends on where the instructions of
fib()
function will be placed. In modern processors, which has 64-byte DSB boundaries, small loops or recursive calls may fit in a single μops cache, but it depends on the code alignment.Here is my experiments for C benchmark:
This alignment issue causes different benchmark results on different platforms, compiler versions, compiler options (e.g. #28), or even what linker you use. If you stick with
fib()
function benchmark, you should manually specify function alignment to get consistent results.The text was updated successfully, but these errors were encountered: