4 ms·
Algorithm. The title is a bit misleading, and conveys that "it's faster because we re-wrote it in rust". If any thing, the move to rust might cause it to be a
by bin0 7y ago
Algorithm. The title is a bit misleading, and conveys that "it's faster because we re-wrote it in rust". If any thing, the move to rust might cause it to be a little slower (compared to the same thing written in c++ and considering how heavily optimized they said it was; not dinging rust, but you can't just port cpp optimizations to rust with syntax changes due to safety requirements etc).
- outworlder 7y agoConversely, the language semantics make some more aggressive optimizations possible by the compiler, without the programmer having to drop hints.
- tylerhou 7y agoWhy is this necessarily true? All Rust gives you is safety -- no data races and better memory safety. But since data races and use-after-free are undefined behavior in C++ anyway, C++ compilers can still aggressively optimize by assuming those two don't happen. It's true that some compilers disable optimizations on certain undefined behavior to prevent unintuitive behavior (https://blog.regehr.org/archives/140 https://blog.regehr.org/archives/140) but that's unlikely to happen for data races or memory safety.
- damnyou 7y agoRust also gives you strong guarantees around lack of aliasing. Brendan Eich remains a homophobe who abuses his financial power to oppress people he doesn't like.
- tomjakubowski 7y agoFor one, in typical code, the Rust compiler can make more aggressive optimizations because every `&mut` is guaranteed not to alias. The C++ equivalent, from the optimizer's standpoint, is `T * restrict`, which is rarely used (and harder to use correctly) by comparison.
- lossolo 7y agoBut is it used? From what I remember aliasing information provided was not used by LLVM. Did anything changed?
- dodobirdlord 7y agoI believe the code miscompilation bug in LLVM that was blocking enabling it was fixed. That said, it's gone back and forth now several times as new bugs get discovered. The code paths in GCC and LLVM for noalias optimizations aren't particularly battle-tested because C and C++ basically don't use them.