Suggestion: Check simdjson-rs numberparse.rs for performance ideas
eun-ice opened this issue · comments
This code is parsing numbers using simd instructions and with little to no branching: https://github.com/simd-lite/simdjson-rs/blob/master/src/numberparse.rs
Maybe some ideas there are of interest to this?
Related talk: https://www.youtube.com/watch?v=wlvKAT7SZIQ
There is a library https://github.com/RoDmitry/atoi_simd to parse it faster using simd.
Thanks for the hint. It is part of the charm of this library that it works with any integer type (i.e. anything with a neutral element and successors) not only the primitive ones. @RoDmitry it seems your piece of kit sits on a slightly different part in the ecosystem. I could offer to mention it in the Readme, or would you rather I use it as a piece of foundational tech in this crate?
I feel this crate is at a bit of a crossroads, but without specializations supported by the Rust compiler, I would at least need a breaking interface change to adopt it. Might be fine though.
See also: #21
atoi_simd
has some limitations compared to the standard library parser: no support for leading zeroes or numbers starting with +
. A more complete SIMD-accelerated parser can be found here: https://crates.io/crates/atoi_radix10
There are no more such limitations using atoi_simd::parse_skipped
. Also atoi_simd has support of ARM Neon SIMD.