3 ms·
Such stark difference in performance is really fishy and needs a deeper analysis. I just checked it with different compilers (all based on LLVM) and here are th
by dagome 4y ago
Such stark difference in performance is really fishy and needs a deeper analysis. I just checked it with different compilers (all based on LLVM) and here are the results:
rustc 1.58 (LLVM 13): By-Copy: 10804, By-Borrow: 7198
rustc 1.64 (LLVM 14): By-Copy: 7385, By-Borrow: 7328
rustc 1.66 (LLVM 15): By-Copy: 2667, By-Borrow: 2777
clang++ (LLVM 14): By-Copy: 2439, By-Ref: 2589
clang++ (LLVM 15): By-Copy: 2473, By-Ref: 2556
When compared with the same LLVM version clang much better utilised LLVM-14 than rustc - C++ is 3x faster. With LLVM-15 they are much closer.
- FpUser 4y agoIs this Windows or Linux? Also what CPU? Your results for rust on LLVM15 are pretty much close to mine but clang++ on LLVM15 is almost twice as slow. I really want to find reason.
- FpUser 4y agoNever mind, figured it out: clang++ -O3 -mavx2 fts_cpp_copy_bench.cpp -o test.exe this did it. The final score is: rust - By-Copy: 2683, By-Borrow: 2697 c++ - By-Copy: 2577, By-Ref: 2600 so C++ seems a bit faster but not by much
- josephg 4y agoAre you enabling avx2 for rust as well? What arguments are you using for rust? Try this: RUSTFLAGS="-C target-cpu=native" cargo run --release # or whatever And: clang++ -O3 -march=native fts_cpp_copy_bench.cpp -o test.exe arch=native will also activate SSE, MMX, and all the other goodies that modern CPUs have to offer.
- FpUser 4y agoSorry for being dumb, I thought I've enabled it in ./cargo/config.toml for rust. Checked it again and it appears that I did not (the file name was wrong). -march=native for CLang also did better than just avx2 rust - By-Copy: 1831, By-Borrow: 1850 c++ - By-Copy: 2411, By-Ref: 2458 Interesting why Rust wins with such a large margin. Maybe will try to find out later.