3 ms·
TLDR: Most of the time C++ with GCC was best.
by sdan 7y ago
TLDR:
Most of the time C++ with GCC was best.
- foota 7y agoWas it? Seemed to swap between rustc and gcc to me.
- vihren 7y agoIt seems that when they squeeze all possible optimizations, GCC was a bit faster, but for the not so optimized code GCC and rustc seem very comparable.
- maeln 7y agoImportant to mention though: The difference was most of the time very slim.
- galangalalgol 7y agoWere you even looking at the same article? Rust was always better at intruction level parralellism and gcc was usually best at cache depending greatly on which i5 xeon was used. Clang was slways the worst.my main takeaway was that they are all three roughly identical and that small processor differences dominated the results.
- fluffy87 7y agoYeah, there were differences, but these were peanuts. Using two different versions of GCC will givenyou similar differences.
- gpderetta 7y agoyes, you can see from the assembly listings in the final stages, that most of the differences were due to very minor code changes, due to details in the optimization passes and not really to language differences.
- gpderetta 7y agoILP is not the correct metric, total runtime is (I was confused as well initially, but it is well explained in the article). the initial rust code had higher ILP simply because it has to execute more code for the bound checks. The C++ code stalls waiting for memory, while rust can fill up those bubbles with the checks (and that's why the checks do not cause slowdown initially). But as the code gets progressively optimized, the stalls are removed and the the C++ code can match the rust ILP, but at this point rust needs to execute more code and get penalized leading to an higher runtime. After the bounds checks are removed from the rust code, both implementations converge to the same ILP and runtime.
- Someone 7y ago"Clang was always the worst” Were you even looking at the same article? :-) I thought the same as you, until I looked at the results for the "Mid-range laptop CPU with 4 physical cores and 8 hardware threads.” There, clang does best in multi-core for v4 through v7. That made me think that, possibly, the default set of LLVM optimization transformation passes in clang is (better) optimised for Apple’s main audience: mobile. Also: why are the fastest run on the “4.3 GHz Mid-range desktop CPU” slower than the equivalent ones on the “3.4 GHz Mid-range laptop CPU”?
- tiborsaas 7y agoMy TLDR: don't base your choice on performance if you have to pick between Rust or C++