[ruby-core:126459] [Ruby Feature#22256] Replace missing/dtoa.c with a uscale-based algorithm. Faster, smaller footprint, and fixes a rounding error.
Issue #22256 has been reported by AndrewDile (Andrew Dile). ---------------------------------------- Feature #22256: Replace missing/dtoa.c with a uscale-based algorithm. Faster, smaller footprint, and fixes a rounding error. https://bugs.ruby-lang.org/issues/22256 * Author: AndrewDile (Andrew Dile) * Status: Open ---------------------------------------- I'm proposing a replacement of `missing/dtoa.c` with a faster, leaner, more correct algorithm. I have [a PR](https://github.com/ruby/ruby/pull/18373) open as a proposed solution, which also provides more details to the origin of the algorithm and its performance compared to `missing/dtoa.c`. This would solve a few edge case rounding issues that currently happen during `Float#to_s`, and it would significantly increase the performance of `Float#to_s` and `String#to_f`, all while unifying both formatting (shortest-width and fixed-width) and parsing under one primitive. -- https://bugs.ruby-lang.org/
Issue #22256 has been updated by byroot (Jean Boussier). [Feature #21308] was filed a while ago. `dtoa.c` is really showing its age, and in the last couple years there has been a lot of new algorithms on that particular topic. Currently `ruby/json` uses Grisu for `double -> string` and Eisel-Lemire fast float for `string -> double`. If these benchmarks are to be believed: https://fmtlib.github.io/dtoa-benchmark/results/, `uscale` while much simpler than alternatives, may not be the best choice. If we're to migrate away from `dtoa.c` I think we might as well consider several alternatives rather than jump straight to `uscale`. So perhaps it'd be best to put [Feature #21308] on the next developer meeting topic to see what the criterias would be for replacement. ---------------------------------------- Feature #22256: Replace missing/dtoa.c with a uscale-based algorithm. Faster, smaller footprint, and fixes a rounding error. https://bugs.ruby-lang.org/issues/22256#change-118674 * Author: AndrewDile (Andrew Dile) * Status: Open ---------------------------------------- I'm proposing a replacement of `missing/dtoa.c` with a faster, leaner, more correct algorithm. I have [a PR](https://github.com/ruby/ruby/pull/18373) open as a proposed solution, which also provides more details to the origin of the algorithm and its performance compared to `missing/dtoa.c`. This would solve a few edge case rounding issues that currently happen during `Float#to_s`, and it would significantly increase the performance of `Float#to_s` and `String#to_f`, all while unifying both formatting (shortest-width and fixed-width) and parsing under one primitive. -- https://bugs.ruby-lang.org/
participants (2)
-
AndrewDile (Andrew Dile) -
byroot (Jean Boussier)