4 ms·
How would Rust compare?
by fouc 8y ago
How would Rust compare?
- galangalalgol 8y agoThe benchmark game puts c, rust, and c++, in that order, roughly on par in performance, with go being about 2-3x slower. No idea if that's accurate. Sampling bias means people who like performance are optimizing the languages used for performance, and people who just like to get something working quit after the first benchmark in go or python is finished. https://benchmarksgame-team.pages.debian.net/benchmarksgame/which-programs-are-fast.html https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
- v_lisivka 8y agoIf you discard regexredux, then Rust is faster than C and C++ at average: see average bar at "How many times slower graph" [1]. regexredux program is outlier in Rust, because replacement of a regex in string is slower in regex crate, because author of regex crate chose to implement safer, but slower algorithm. To fix this, regex crate must be updated or replaced. I spent two weekends on this. [1]: https://benchmarksgame-team.pages.debian.net/benchmarksgame/which-programs-are-fast.html https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
- igouy 8y agomandelbrot is outlier in Rust, because… :-)
- v_lisivka 8y agoBecause hardware acceleration is used in C and C++ versions. I will fix this soon.
- igouy 8y ago> To fix this, regex crate must be updated or replaced. I somehow doubt pcre2 is being changed to make the tiny toy C programs run better. > I spent two weekends on this. So shouldn't we assume the program performance simply reflects all-those-hours you've spent working on it?
- v_lisivka 8y agoLook at the program: fn find_replaced_sequence_length(sequence: String) -> usize { // Replace the following patterns, one at a time: let substs = vec![ ("tHa[Nt]", "<4>"), ("aND|caN|Ha[DS]|WaS", "<3>"), ("a[NSt]|BY", "<2>"), ("<[^>]*>", "|"), ("\\|[^|][^|]*\\|", "-"), ]; // Perform the replacements in the sequence: substs .iter() .fold(sequence, |s, (re, replacement)| { regex(re) .replace_all(&s, NoExpand(replacement)).into_owned() }).len() } It measures performance of RE engine. I can switch from regex crate to PCRE2, and program performance will match C.
- igouy 8y ago> I can switch from regex crate to PCRE2, and program performance will match C. Perhaps it would; those measurements have not been made. What does that have to do with re-writing libraries to make tiny toy programs run better? What does that have to do with program performance being a proxy for programmer effort?
- igouy 8y ago> Sampling bias means people who like performance are optimizing the languages used for performance … Also, there might be a something to prove "bias" :-)
- galangalalgol 8y agoAlso, Dropbox rewrote the core stuff from go to rust when they needed more performance. So that is one example/anecdote.
- v_lisivka 8y agoConcurrency in Rust is extremely easy, because it safe by design. Just import rayon crate and change iter() to par_iter() [1]. Compiler will point out to problems, e.g. it will not allow to send a type, which cannot be used concurrently, until it will be wrapped by Arc (atomic reference counter). [1]: https://docs.rs/rayon/1.0.3/rayon/ https://docs.rs/rayon/1.0.3/rayon/