Hacker News new | past | comments | ask | show | jobs | submit login

I was competing against some C and C++ software developers in Advent of Code with efficient solutions, and my Rust solutions came out faster each time. Might want to check your facts.



That doesnt mean anything. Try a little real software for instance.



No, like: crypto, math, compression, encoding/decoding. Any example?



Very good example in fact. Seems roughly the same.


Like ripgrep?


Question, grep is multi-threaded?


GNU grep is not multi-threaded.

Since you chose to be cute, I'm going to take a guess that you think this means the comparison between the tools is unfair. If that's an accurate interpretation, then I will say that your question is irrelevant because ripgrep is faster or as fast as GNU grep on benchmarks using a single thread too. In fact, that's the whole point! It says so right in the project's README.

http://blog.burntsushi.net/ripgrep/#single-file-benchmarks


Ok, interesting analysis. I will look more on Rust and maybe try something myself. But by reading your other posts about optimizing Rust to do search, it seems to require a lot of experience to tune Rust code.


Building ripgrep did require a lot of experience, indeed, but it had almost nothing to do with Rust. The experience is in text search specifically, which you'll need regardless of the language you're using. If you look at the regex crate for example, there's basically no use of unsafe at all. The only use is to elide bounds checks in some very carefully crafted tight loops. But again, most of that work was done irrespective of Rust and just figuring out the right way to unroll the DFA loop(s).

Optimization tricks in Rust are the same as you'll find in C++. It might be worth you comparing the C++ implementation of Snappy with my Rust implementation, for example. You'll see the same kinds of tricks employed in C++ as in Rust (avoiding memcpy in favor of unaligned loads/stores).




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: