Open digitalinfinity opened 6 years ago
I believe this is the same as the chakracore issue https://github.com/Microsoft/ChakraCore/issues/2512
Isolated repro:
(100.0/11).toString(10);
They expect output: 9.090909090909092 We output: 9.090909090909091
Debugger shows all three numbers as 9.0909090909090917165
a2e8ba2f 40222e8b
00101111 10111010 11101000 10100010 2f ba e8 a2
10001011 00101110 00100010 01000000 8b 2e 22 40
Note: we have separate code path for decimal conversion.
FDblToRgbPrecise produces 9.090909090909092 representation. FDblToRgbFast (which we end up using) produces 9.090909090909091 representation.
FDblToRgbFast hasn't changed since 2006 (other than handling errors and moving helpers into namespace).
Hiding FDblToRgbPrecise behind FDblToRgbFast goes as far back as 2002 (without any interesting comments on why it's this way).
Did a mini-benchmark: in x86 Release build FDblToRgbPrecise is about 2.8 times slower than FDblToRgbFast (a loop over 10^6 doubles: 733949944 & 263994008 nanoseconds).
Replacing FDblToRgbFast with FDblToRgbPrecise regressed the following benchmarks: Kraken: Json-stringify-tinderbox (19%) Octane: Splay (14%), Splay latency (6%) SunSpider: String-tagcloud (5-17%)
Discussed with Louis and he thinks regressing perf of JSON.stringify like this isn't acceptable: JSON.stringify({ 'pi': 3.14 }) calls ToString and it's not inconceivable to have real life scenarios with json describing objects with many floating point properties.
JSON I can see- why does splay regress with that change? I thought Splay was memory intensive. Is the String-tagcloud case also using JSON stringify in the hot path?
Splay test generates a new random number and then converts it to string in a loop (see InsertNewNode()). Ends up calling ToString 10K+ times.
String-tagcloud creates "a href" tag using popularity numbres, which are converted to string. Calls ToString 2.5K+ times.
Repro steps (attempted on Linux):
Result: 26 pass, 1 fail