News for hackers. Stuff that matters.
Re:Fast function to parse strings into double (binary64) flo... by zozbot234 on Tuesday March 10, 2020 @08:30PM (#22541624)
Great hack, but in a broader sense this is silly. If parsing/pretty-printing floats from/to ASCII strings is a bottleneck you should be using hexfloats, as supported in the latest C/C++ standards and elsewhere. As a bonus, they will reliably evaluate to the same floating point number, eliminating an extra source of ambiguity and possible overhead.
Re:Fast function to parse strings into double (binary64) flo... by chadaustin on Tuesday March 10, 2020 @08:51PM (#22541798)
It can be a big chunk of the cost of parsing JSON.
Re:Fast function to parse strings into double (binary64) flo... by gameswithgo on Tuesday March 10, 2020 @10:41PM (#22542447)
stop using json is the message
Re:Fast function to parse strings into double (binary64) flo... by blacklion on Wednesday March 11, 2020 @11:43AM (#22546717)
I dream about day when all cryptoexchanges get this message. Not today :-(
Re:Fast function to parse strings into double (binary64) flo... by thedance on Tuesday March 10, 2020 @10:27PM (#22542366)
It's not silly at all. Replacing a lot of sprintf calls with Grisu and later Ryu made a huge difference in the production fleet at my last job. It wasn't by any means "the bottleneck" but it was costing real money. Most of the calls were in peripheral functions like debug logs, status page outputs, and whatnot.

That said, I've never seen strtod showing up in my profiles, but I bet if I was profiling web browsers then I would see it.

Re:Fast function to parse strings into double (binary64) flo... by MaxBarraclough on Friday March 13, 2020 @07:54AM (#22566543)
I was wondering if ctrl-f for 'Ryu' would match anything.

Jeroen van der Zijp, developer of the lesser known FOX Toolkit, claims to have done better than the Ryu algorithm. From his changelist [0]:

> New, faster, and often more accurate floating point to string conversion. No, this is not based on Ryu paper. New method reliably generates 16 digits, and does much better rounding.

I believe this [1] is his implementation in C++. See also his paper [2]. (I believe it's not peer-reviewed, but it does appear in Google Scholar.)

[0] http://www.fox-toolkit.org/

[1] https://github.com/gogglesguy/fox/blob/77396c638c1c4e05/lib/...

[2] http://www.fox-toolkit.org/ftp/fasthalffloatconversion.pdf

Re:Fast function to parse strings into double (binary64) flo... by zone411 on Tuesday March 10, 2020 @10:46PM (#22542472)
This conversion was a profiler-verified bottleneck in my projects twice. Nothing silly about it.