Re:Single_file_libs: List of single-file C/C++ libraries
by steveklabnik on Monday October 26, 2020 @11:44AM
(#24897401)
We have seen some of this; Dropbox has a macro that lets them turn off checks with a feature flag, for example, because it had a noticeable impact.
Re:Single_file_libs: List of single-file C/C++ libraries
by ATsch on Monday October 26, 2020 @12:07PM
(#24897651)
Ah, that's interesting, I assume this is the link:
https://dropbox.tech/infrastructure/lossless-compression-wit...
Shows a significant improvement in compression code and some examples of checks that can't be elided. I guess this makes sense because it's pretty much the worst case scenario for bounds check impact.
I can still personally say that every time I've blamed rust's bounds checks, I was wrong.
EDIT: neither the unsafe flag nor the macro appear to be present in https://github.com/dropbox/rust-brotli/ anymore today, removed some time in 2017. So it seems they found some other way to deal with it?
Re:Single_file_libs: List of single-file C/C++ libraries
by steveklabnik on Monday October 26, 2020 @01:22PM
(#24898597)
Ah interesting! Glad they removed it. I can't quite find out when, and I don't have the time to really dig in right now. Very cool, thanks.
The only exception I can think of is accessing lots of indexes in a loop, where getting good performance requires rust programmers to insert awkward asserts or casts to fixed length arrays to get the checks to optimize out[1]. But afaik that's mostly because the bound checks impede other loop optimisations like vectorization, not because the checks are slow themselves.
[1] (e.g. when you access indexes 1 to n randomly, assert n < length before)