fast-float-rust does not handle disguised fast path cases, such as "1.2345e30", and therefore falls back to compute_float when it's unnecessary. The changes are trivial, and lead to ~30% performance improvements for disguised fast-path cases without affecting other benchmarks. See rust-dec2flt for exact specifics on these benchmarks.
Benchmarks
These benchmarks were run on an i7-6560U CPU @ 2.20GHz, on a target of x86_64-unknown-linux-gnu, running kernel version 5.11.16-100, on a Rust version of rustc 1.53.0-nightly (132b4e5d1 2021-04-13). The performance CPU governor was used for all benchmarks, and were run consecutively on A/C power with only tmux and Sublime Text open for all benchmarks. The floats that were parsed are as follows:
// Example fast-path value.
const FAST: &str = "1.2345e22";
// Example disguised fast-path value.
const DISGUISED: &str = "1.2345e30";
// Example moderate path value: clearly not halfway `1 << 53`.
const MODERATE: &str = "9007199254740992.0";
// Example exactly-halfway value `(1<<53) + 1`.
const HALFWAY: &str = "9007199254740993.0";
// Example large, near-halfway value.
const LARGE: &str = "8.988465674311580536566680e307";
// Example denormal, near-halfway value.
const DENORMAL: &str = "8.442911973260991817129021e-309";
Note: I ran these benchmarks numerous times, to try to ensure fast-float/fast was at least as fast as those for the disguised case, but they never were. Since this introduced an additional branch when parsing, we should assume that the fast-path case is at least as fast here as on the disguised branch.
Issue
fast-float-rust does not handle disguised fast path cases, such as
"1.2345e30"
, and therefore falls back tocompute_float
when it's unnecessary. The changes are trivial, and lead to ~30% performance improvements for disguised fast-path cases without affecting other benchmarks. See rust-dec2flt for exact specifics on these benchmarks.Benchmarks
These benchmarks were run on an i7-6560U CPU @ 2.20GHz, on a target of x86_64-unknown-linux-gnu, running kernel version 5.11.16-100, on a Rust version of rustc 1.53.0-nightly (132b4e5d1 2021-04-13). The performance CPU governor was used for all benchmarks, and were run consecutively on A/C power with only tmux and Sublime Text open for all benchmarks. The floats that were parsed are as follows:
disguised
master
Note: I ran these benchmarks numerous times, to try to ensure
fast-float/fast
was at least as fast as those for thedisguised
case, but they never were. Since this introduced an additional branch when parsing, we should assume that the fast-path case is at least as fast here as on the disguised branch.DIff
The changes are trivial, and do not affect binary size: