summaryrefslogtreecommitdiff
path: root/tests/integration
diff options
context:
space:
mode:
authorfilipe oliveira <filipecosta.90@gmail.com>2022-10-15 10:17:41 +0100
committerGitHub <noreply@github.com>2022-10-15 12:17:41 +0300
commit29380ff77d5da51d3065b810a9f93171f8724c1a (patch)
treed40fb96981280f3dd5ddea2833997cfc88d28b35 /tests/integration
parent9ab873d9d35e789a228c5281d57c9c4fdc1e4ce1 (diff)
downloadredis-29380ff77d5da51d3065b810a9f93171f8724c1a.tar.gz
optimizing d2string() and addReplyDouble() with grisu2: double to string conversion based on Florian Loitsch's Grisu-algorithm (#10587)
All commands / use cases that heavily rely on double to a string representation conversion, (e.g. meaning take a double-precision floating-point number like 1.5 and return a string like "1.5" ), could benefit from a performance boost by swapping snprintf(buf,len,"%.17g",value) by the equivalent [fpconv_dtoa](https://github.com/night-shift/fpconv) or any other algorithm that ensures 100% coverage of conversion. This is a well-studied topic and Projects like MongoDB. RedPanda, PyTorch leverage libraries ( fmtlib ) that use the optimized double to string conversion underneath. The positive impact can be substantial. This PR uses the grisu2 approach ( grisu explained on https://www.cs.tufts.edu/~nr/cs257/archive/florian-loitsch/printf.pdf section 5 ). test suite changes: Despite being compatible, in some cases it produces a different result from printf, and some tests had to be adjusted. one case is that `%.17g` (which means %e or %f which ever is shorter), chose to use `5000000000` instead of 5e+9, which sounds like a bug? In other cases, we changed TCL to compare numbers instead of strings to ignore minor rounding issues (`expr 0.8 == 0.79999999999999999`)
Diffstat (limited to 'tests/integration')
-rw-r--r--tests/integration/rdb.tcl2
1 files changed, 1 insertions, 1 deletions
diff --git a/tests/integration/rdb.tcl b/tests/integration/rdb.tcl
index 104d372e1..1dd6bb1d7 100644
--- a/tests/integration/rdb.tcl
+++ b/tests/integration/rdb.tcl
@@ -29,7 +29,7 @@ start_server [list overrides [list "dir" $server_path "dbfilename" "encodings.rd
"0","set_zipped_2","set","100000","200000","300000","400000",
"0","set_zipped_3","set","1000000000","2000000000","3000000000","4000000000","5000000000","6000000000",
"0","string","string","Hello World"
-"0","zset","zset","a","1","b","2","c","3","aa","10","bb","20","cc","30","aaa","100","bbb","200","ccc","300","aaaa","1000","cccc","123456789","bbbb","5000000000",
+"0","zset","zset","a","1","b","2","c","3","aa","10","bb","20","cc","30","aaa","100","bbb","200","ccc","300","aaaa","1000","cccc","123456789","bbbb","5e+9",
"0","zset_zipped","zset","a","1","b","2","c","3",
}
}