6 ms·
The Rust benchmarks will become a lot more interesting (and realistic) when they don't rely so heavily on unsafe calls to C code.
by biggest_lou 12y ago
The Rust benchmarks will become a lot more interesting (and realistic) when they don't rely so heavily on unsafe calls to C code.
- dfkf 12y agoOnly three rust benchmarks use unsafe code, in one of them it's virtually mandatory, and in another it's just one line. On a side note, rust compiler enforces naming conventions, which is kind of cute.
- tuxychandru 12y agoThe reverse complement program certainly doesn't need unsafe code, but the safe rust version[1] takes 3x the execution time of the unsafe rust version[2]. By comparison the fastest Go version[3] is fairly idiomatic Go without unsafe memory management and takes just 2x the time of the unsafe rust version. Also, which benchmark did you have in mind when you said unsafe code is mandatory? [1] http://benchmarksgame.alioth.debian.org/u64q/program.php?test=revcomp&lang=rust&id=2 http://benchmarksgame.alioth.debian.org/u64q/program.php?tes... [2] http://benchmarksgame.alioth.debian.org/u64q/program.php?test=revcomp&lang=rust&id=4 http://benchmarksgame.alioth.debian.org/u64q/program.php?tes... [3] http://benchmarksgame.alioth.debian.org/u64q/program.php?test=revcomp&lang=go&id=1 http://benchmarksgame.alioth.debian.org/u64q/program.php?tes...
- dbaupp 12y agoThat specific safe version, which, IIRC, was a basic translation of the fastest C version. I'd guess that there's other safe variations that are more idiomatic and much faster.
- tuxychandru 12y agoMay be a faster safe version should be contributed. The current state is that unsafe rust takes half as much time as a safe go program in this benchmark. That is not very interesting because the benefits offered by rust are being given up to perform better, for a problem that doesn't really need unsafe memory access. Same is the case with spectral norm. It is unsafe rust beating safe go there too.
- arthursilva 12y agoThese are REALLY BAD examples, the safe rust version isn't parallelized but the two others are. The unsafe version is just translated C as people already stated. A safe version these days (heading towards 1.0) shouldn't be far of the unsafe versions.
- igouy 12y agoSo contribute what you consider to be safe Rust programs.
- smosher_ 12y agoThe unsafe calls to C all seem to be in the gmp^H^H^Hpidigits benchmark. It's unrealistic to avoid gmp in this scenario.
- dbaupp 12y agoOne can definitely make a case for pidigits mainly being an FFI benchmark.
- kxo 12y agoUnsafe is not something that needs to be avoided. Small, widely-verified blocks of unsafe code should be the norm if unsafe code is necessary. This does not mean "if you're using unsafe you've failed!"