Bug 221178 - Investigate replacing double_conversion library with fast_float
Summary: Investigate replacing double_conversion library with fast_float
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Yusuke Suzuki
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-01-30 08:41 PST by Sam Weinig
Modified: 2022-12-10 16:11 PST (History)
13 users (show)

See Also:


Attachments
experiment (98.02 KB, patch)
2021-02-03 23:22 PST, Yusuke Suzuki
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (106.24 KB, patch)
2021-02-03 23:59 PST, Yusuke Suzuki
ews-feeder: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sam Weinig 2021-01-30 08:41:15 PST
For a while now, we have been using V8's double_conversion library for double/float parsing, but we should consider replacing it with Daniel Lemire's fast_float, https://github.com/fastfloat/fast_float, which reports even better performance.
Comment 1 Yusuke Suzuki 2021-01-30 11:00:54 PST
Sounds interesting! We know that double->string conversion is actually super important (frequently done for debugging, JSON, etc.). So if this is faster, it is definitely worth doing :)
Comment 2 Yusuke Suzuki 2021-01-30 11:05:54 PST
https://github.com/apache/arrow/pull/8494 Apache Arrow replaced double_conversion from fast_float and observing performance improvement.
Comment 3 Yusuke Suzuki 2021-01-30 11:06:24 PST
Note that, if it is faster, we could see improvement in Speedometer2/EmberJS-Debug
Comment 4 Yusuke Suzuki 2021-01-30 11:11:38 PST
Ah, no. EmberDebug is for double->string. This library is string->double. So some of JSON benchmark can get benefit.
Comment 5 Sam Weinig 2021-01-30 12:41:12 PST
(In reply to Yusuke Suzuki from comment #4)
> Ah, no. EmberDebug is for double->string. This library is string->double. So
> some of JSON benchmark can get benefit.

There are a few other things that might help that case.

1) We could try updating the version of double_conversion we have to the latest release. Not sure how long it's been since we last pulled in anything, so there might just be free wins there,

2) There are other libraries and papers that focus on the float -> string case:
- https://github.com/abolz/Drachennest/
- the MSVC STL has a supposedly very fast version in std::to_chars (https://youtu.be/4P_kbF0EbZM is a fun talk if you are into that kind of thing)
- https://news.ycombinator.com/item?id=24917659 has some additional discussion
Comment 6 Sam Weinig 2021-02-02 05:32:08 PST
https://github.com/apple/swift/pull/35299 might also be of interest for the opposite case.
Comment 7 Yusuke Suzuki 2021-02-03 23:22:20 PST
Created attachment 419243 [details]
experiment
Comment 8 Radar WebKit Bug Importer 2021-02-03 23:46:00 PST
<rdar://problem/73968546>
Comment 9 Yusuke Suzuki 2021-02-03 23:57:27 PST
                                 ToT                     Patched

json-parse-financial        28.051+-0.094      ^      27.630+-0.134         ^ definitely 1.0152x faster

In Kraken's json-parse-financial, 1.5% faster (w/ 100 iteration).
Comment 10 Yusuke Suzuki 2021-02-03 23:59:03 PST
Created attachment 419256 [details]
Patch
Comment 11 Yusuke Suzuki 2021-02-04 00:43:50 PST
We should kill int/nan etc. conversion feature.
Comment 12 Darin Adler 2021-02-04 10:00:36 PST
One of the things I suggest we do is continue keep the interface to our string to floating point and floating point to string functions narrow so it’s straightforward for us to improve the implementation. I’ve tried to do this before, removing unnecessary entry points and variants and making the interface as clear as possible, while trying to stay careful to still allow us to have excellent performance.

I am so excited to hear that fast_float looks so promising to improve performance!
Comment 13 Sam Weinig 2021-02-04 20:35:42 PST
(In reply to Yusuke Suzuki from comment #9)
>                                  ToT                     Patched
> 
> json-parse-financial        28.051+-0.094      ^      27.630+-0.134        
> ^ definitely 1.0152x faster
> 
> In Kraken's json-parse-financial, 1.5% faster (w/ 100 iteration).

Nice!
Comment 14 Yusuke Suzuki 2022-07-26 23:45:01 PDT
Pull request: https://github.com/WebKit/WebKit/pull/2772
Comment 15 EWS 2022-12-09 22:56:34 PST
Committed 257675@main (178e0726ac6b): <https://commits.webkit.org/257675@main>

Reviewed commits have been landed. Closing PR #2772 and removing active labels.
Comment 16 Simon Fraser (smfr) 2022-12-10 16:11:11 PST
Does this impact float parsing in CSS and SVG?