4 ms·
Rust is slower than C++?
by wffurr 7y ago
Rust is slower than C++?
- The_rationalist 7y agoYes, at best 20% slower but can be far more slower if you hit worst case scenario.
- johnzabroski 7y agoWhy is Mozilla Firefox written in Rust, then? The last time I looked at browser benchmarks was in 2016 when Google released benchmarks to brag about its performance over Firefox and Edge. It appears Webkit has released JetStream2 to benchmark JavaScript, WebAssembly and web workers, among other things. But I can't find data showing Mozilla Firefox is ~20% slower than Chrome/Edge today.
- dthul 7y agoUsing Firefox to evaluate Rust performance is probably not a good idea since only parts of it are written in Rust today. But it's the first time I hear someone say that Rust is supposedly fundamentally slower than C++. I don't believe this to be a statement that can be substantiated, seeing that some of the fastest programs out there (ripgrep and hyper to name just two) are written in Rust.
- pdimitar 7y agoIMO the jury is still out. I am pretty sure that C++ veterans that can cleverly utilise any and all performance tricks (minus resorting to an assembly language) and can thus beat any other language. But I -- like yourself -- am much more interested in the applicability of a language in everyday tools, plus in getting the most performance with the least amount of dark magic involved. BTW, `ripgrep` definitely made me work better and faster.
- The_rationalist 7y agoFacts: On average rust is 10% slower on the banchmarkgame: https://benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/gpp-rust.html https://benchmarksgame-team.pages.debian.net/benchmarksgame/... But they use llvm instead of gcc for c++, and gcc is in average 20% faster than clang. Therefore, rust is 30% slower, at least on heavily optimised programs. And hyper is not the fastest http server, but the actix one is one of the fastest yes.
- steveklabnik 7y ago> Facts: On average rust is 10% slower on the banchmarkgame That does not show it's 10% slower on average; it shows that C++ is 0.9917938291x as fast as Rust. They both have some where they win by 30%, most are closer, Rust is just faster on average. > But they use llvm instead of gcc for c++, C++ g++ g++ (Ubuntu 9.2.1-9ubuntu2) 9.2.1 20191008 ? > gcc is in average 20% faster than clang. Extremely citation needed.
- igouy 7y ago> faster on average What kind-of time measurements? What kind-of average? This chart shows some time measurements: https://benchmarksgame-team.pages.debian.net/benchmarksgame/which-programs-are-fastest.html https://benchmarksgame-team.pages.debian.net/benchmarksgame/... :and the geometric mean is faster for the C++ programs, but the median seems faster for the rust programs. Statistical artifacts?
- steveklabnik 7y ago> What kind-of time measurements? What kind-of average? I interpreted the parent to mean a simple average, so I did exactly that: calculated the percentage for each, and averaged them. In the colloquial term, "mean".
- The_rationalist 7y agoGeometric mean is the implicit default measurement for benchmarking
- The_rationalist 7y agoFirefox is far more than 20% slower than Chrome today but is not strictly a direct cause of using rust. https://www.phoronix.com/scan.php?page=article&item=firefox-70-chrome-78&num=1 https://www.phoronix.com/scan.php?page=article&item=firefox-...
- Ygg2 7y agoWhere did you pull those numbers? Looking at https://benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/gpp-rust.html https://benchmarksgame-team.pages.debian.net/benchmarksgame/... While the worst case is 40% slower (where even C perfored abysmally), most of the time the Rust is within a 10% margin of error, and in quite a few cases it's faster.
- NoZZz 7y agoStrange benchmark, comparing llvm(rust) to gcc(c++ code)
- The_rationalist 7y agoAs nozzz said, this is using clang. So I should correct my statement, c++ is in average 30% faster as gcc is in average 20% faster than llvm.
- gameswithgo 7y ago"at best 20%" slower is a clearly non factual statement. Probably the one scenario where it would be far more slower than that would be a heavily AVX-512 intrinsics program because Rust doesn't have those yet (I think), but then that isn't really either language anymore. its intrinsics.
- The_rationalist 7y agoRe-read as 30% slower in average and then it's a factual statement.
- pdimitar 7y agoI am undecided on it since I am not in the C++ ecosystem for a long time now, and I am just a beginner in Rust. I get the message there are ways to write suboptimal (in terms of performance) code in Rust as well but I also keep hearing there are much less ways to shoot oneself in the foot, which works very well for me. Truthfully, even if Rust can be 2x-5x slower than C++ somewhere, I'll still choose it as my static-and-strongly-typed / compiled-to-machine-code language regardless. Least WTFs per minute is my most important metric. But I am open to see any and all benchmarks which show both strengths and weaknesses of Rust. So far I sadly haven't seen many of them (but I've been mightily impressed by `actix` in the TechEmpower benchmarks!).