-
Notifications
You must be signed in to change notification settings - Fork 18k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
strconv: optimize ParseFloat with new refloat algorithm #66327
Comments
Please add the output of golang.org/x/perf/cmd/benchstat comparing the benchmark output, run with |
Hi, thank you for commenting. I had to rerun the benchmark since I didn't specify
|
@sugawarayuuta this is great! Thanks for sharing. It would be great if you send a change to optimize the strconv package. See https://go.dev/doc/contribute for how to contribute to Go, if you haven't seen it. Thanks! |
CC @griesemer |
Hi, kind of unfortunate. I tried to apply my parser to the |
@sugawarayuuta nice work and thank you, please go ahead with firstly sending the change for readFloat, we appreciate it and look forward to interacting with you on your change! Later on, with enough time we can figure out how to completely transform your work for the whole of ParseFloat. |
Change https://go.dev/cl/572235 mentions this issue: |
Floating point conversions are used in many places such as
encoding/json
. While the current Eisel-Lemire is efficient, you can actually use smaller lookup table and reduce execution time at the same time.I implemented this algorithm in Go from start and now it's available through BSD-3-Clause license: https://github.com/sugawarayuuta/refloat
We can see that it performs mostly better on normally distributed (
norm
) floats and bit-wise uniform floats (bits
).Benchmarks are done on multiple machines - they did produce results very similarly.
Especially normally distributed
float64
has a significant change (~41%) which will fit in many real use-cases.passes parse-number-fxx-test-data, the standard libraries' tests and I'm doing active fuzz testing in addition comparing outputs to the current
strconv
. so far the only detected problem seems to be the issue 42436 which is a problem withstrconv
only.I actually used an external tool to generate polynomial approximations (Which is not distributed through the same license as the project itself). Do tell me if it can be a problem...
The text was updated successfully, but these errors were encountered: