4 ms·
So I’m confused about the results. Is the engine faster because of rust or because of improvements to the algorithm?
by gregorygoc 7y ago
So I’m confused about the results. Is the engine faster because of rust or because of improvements to the algorithm?
- spooneybarger 7y agoSounds like algo.
- bin0 7y agoAlgorithm. 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.
- sixplusone 7y agoIt's a new, faster algorithm with rule pattern matching. The language is only mentioned once as an implementation detail, not that rust's 69x faster than C++.
- krispbyte 7y agoAccording to https://github.com/brave/adblock-rust https://github.com/brave/adblock-rust they use a similar algorithm as uBlock Origin. So not really "new", just reimplemented in rust.
- pythux 7y agoIt’s actually a Rust implementation of https://github.com/cliqz-oss/adblocker https://github.com/cliqz-oss/adblocker. So you can interpret the difference in the chart between Ghostery and Brave as being how much Rust improved performance over Node.js
- anreekoh 7y agoIMO when anything is rewritten (usually in a modern language), it's faster than the original implementation. That's usually because you have much better hindsight since the entire implementation is finished before the rewrite is started. I'm sure the more modern languages also help though, but I don't think that using a modern language is the major reason for the speedup.
- agumonkey 7y agoLanguages aren't "fast" per se, but a language will help you converge with better ideas faster. It's a regular working process.. use a language that let you write ideas down and test them quick. Later reimplement them in assembly. I mean C.