Commit Graph
178 Commits
Author SHA1 Message Date
Nigel Tao 5477132298 Have std/png verify PLTE chunk checksums 2021-01-21 20:21:33 +11:00
Nigel Tao a1c22caa15 Rename load and store to peek and poke 2021-01-17 22:44:39 +11:00
Nigel Tao f473ffa050 Deprecate script/preprocess-wuffs.go 2020-12-18 22:10:16 +11:00
Nigel Tao 6775c05c08 Have etc-parse-number-f64.cc test fast_float 2020-10-24 17:44:06 +11:00
Nigel Tao 93f9550720 Update manual-test-parse-number-f64.cc data repo 2020-10-23 18:46:12 +11:00
Nigel Tao ba3818cb6b Add more parse_number_f64 test cases 2020-09-28 12:51:45 +10:00
Nigel Tao 6c2fb9a2fd Tweak test/data/artif*/gif-transparent-index.gif 2020-09-27 00:09:25 +10:00
Nigel Tao 344123b179 Add test/data/artificial/gif-transparent-index.gif 2020-09-25 23:01:43 +10:00
Nigel Tao afe7f27ab7 Trim Eisel-Lemire powers-of-10 tables
This tracks the upstream github.com/lemire/fast_double_parser

On a mid-range x86_64 laptop, processing the 181 MiB citylots.json file
from github.com/zemirco/sf-city-lots-json:

$ g++ -O3 script/process-json-numbers.c
$ time ./a.out -parse-number-f64 < citylots.json
Before/After:
real    0m1.035s
real    0m1.003s

Binary size, before:
29544 gen/lib/c/clang-9-dynamic/wuffs-base-floatconv.lo
29648 gen/lib/c/clang-9-static/wuffs-base-floatconv.o
31192 gen/lib/c/gcc-dynamic/wuffs-base-floatconv.lo
31160 gen/lib/c/gcc-static/wuffs-base-floatconv.o

After:
27160 gen/lib/c/clang-9-dynamic/wuffs-base-floatconv.lo
27264 gen/lib/c/clang-9-static/wuffs-base-floatconv.o
28760 gen/lib/c/gcc-dynamic/wuffs-base-floatconv.lo
28760 gen/lib/c/gcc-static/wuffs-base-floatconv.o
2020-09-23 16:18:27 +10:00
Nigel Tao b6d855210c Use a formula to calculate Eisel-Lemire power-of-2
On a mid-range x86_64 laptop, processing the 181 MiB citylots.json file
from github.com/zemirco/sf-city-lots-json:

$ g++ -O3 script/process-json-numbers.c
$ time ./a.out -parse-number-f64 < citylots.json
Before/After:
real    0m0.992s
real    0m1.035s
2020-09-23 15:23:12 +10:00
Nigel Tao cd4cbc9102 Tweak JSON trailing comment/new-line quirks 2020-09-22 23:03:49 +10:00
Nigel Tao f2be4dd7cf Trim private_implementation__powers_of_10 array
Binary size, before:
30344 gen/lib/c/clang-9-dynamic/wuffs-base-floatconv.lo
30488 gen/lib/c/clang-9-static/wuffs-base-floatconv.o
31992 gen/lib/c/gcc-dynamic/wuffs-base-floatconv.lo
31992 gen/lib/c/gcc-static/wuffs-base-floatconv.o

After:
29512 gen/lib/c/clang-9-dynamic/wuffs-base-floatconv.lo
29656 gen/lib/c/clang-9-static/wuffs-base-floatconv.o
31160 gen/lib/c/gcc-dynamic/wuffs-base-floatconv.lo
31160 gen/lib/c/gcc-static/wuffs-base-floatconv.o
2020-09-15 22:14:30 +10:00
Nigel Tao ddac2c50ee Add more {parse,render}_number_f64 test cases 2020-09-15 21:17:33 +10:00
Nigel Tao 57d47c633c Fix etc__high_prec_dec__to_f64 shift amount
Shifting 0.299 left by 2 doesn't put us in [½ .. 1].
2020-09-08 16:43:31 +10:00
Nigel Tao 1210340e75 Add script/manual-test-parse-number-f64.cc 2020-09-07 23:11:07 +10:00
Nigel Tao 510c230cf4 Rename USE_FAST_DOUBLE_PARSER macro 2020-09-07 22:59:45 +10:00
Nigel Tao a20a2bbe56 Fix "stand-alone C++" typo 2020-09-07 21:06:58 +10:00
Nigel Tao 6344181b96 Add look-up table for JSON ASCII escapes
On a mid-range x86_64 laptop, processing the 181 MiB citylots.json file
from github.com/zemirco/sf-city-lots-json:

$ time gen/bin/example-jsonptr < citylots.json > /dev/null
Before this commit:
real    0m1.799s
After:
real    0m1.765s
Ratio: 1.02x
2020-08-21 14:11:31 +10:00
Nigel Tao 1adbc9547f Split std/json's QUIRK_ALLOW_BACKSLASH_X in two 2020-08-06 23:28:07 +10:00
Nigel Tao 1e96ef200c Add test/data/cbor-rfc-7049-examples.* 2020-07-27 22:00:28 +10:00
Nigel Tao 0054a053f5 Add comment link to github.com/cbor/test-vectors 2020-07-24 22:47:39 +10:00
Nigel Tao 271680333e Have std/cbor parse tags 2020-07-24 15:54:44 +10:00
Nigel Tao c9d4e34dfc Split ETC__VBC__INLINE_INTEGER into {,un}signed 2020-07-21 15:31:49 +10:00
Nigel Tao 4e193599ac Add std/cbor 2020-07-15 14:08:37 +10:00
Nigel Tao fcb6416c16 Add script/extract-cbor-rfc-7049-examples.go 2020-07-10 22:56:47 +10:00
Nigel Tao 27766aedf9 Let process-json-numbers use fast_double_parser 2020-07-09 10:59:54 +10:00
Nigel Tao 6b7ce30e32 Add wuffs_base__parse_number_xxx options arg 2020-07-07 16:19:46 +10:00
Nigel Tao 86093c8194 Have parse_number_f64 use the Eisel algorithm
The algorithm is discussed at
https://lemire.me/blog/2020/03/10/fast-float-parsing-in-practice/

----

Binary size, before:
27848 gen/lib/c/clang-5.0-dynamic/wuffs-base-f64conv.lo
28040 gen/lib/c/clang-5.0-static/wuffs-base-f64conv.o
30392 gen/lib/c/gcc-dynamic/wuffs-base-f64conv.lo
30392 gen/lib/c/gcc-static/wuffs-base-f64conv.o

After:
29416 gen/lib/c/clang-5.0-dynamic/wuffs-base-f64conv.lo
29688 gen/lib/c/clang-5.0-static/wuffs-base-f64conv.o
31792 gen/lib/c/gcc-dynamic/wuffs-base-f64conv.lo
31792 gen/lib/c/gcc-static/wuffs-base-f64conv.o

The binary size difference does not account for the powers-of-10 table,
which was expanded in a previous commit in anticipation of this one. A
future commit will also remove some of the other f64 parser code used
before implementing the Eisel algorithm.

----

Processing citylots.json from github.com/zemirco/sf-city-lots-json
$ g++ -O3 script/process-json-numbers.c
$ time ./a.out -parse-number-f64 < citylots.json
Before/After:
real    0m1.231s
real	0m1.031s

The difference with and without -parse-number-f64 measures how much time
is spent in the parse_number_f64 function. Before: 424ms, after: 224ms.
$ time ./a.out                   < citylots.json
real	0m0.807s

Similarly, for canada.json from github.com/miloyip/nativejson-benchmark
$ time ./a.out -parse-number-f64 < canada.json
Before/After:
real	0m0.023s
real	0m0.017s
$ time ./a.out                   < canada.json
real	0m0.013s
Time spent in parse_number_f64, before: 10ms, after: 4ms.

----

name                                                old time/op  new time/op   delta
wuffs_strconv_parse_number_f64_1_lsh53_add0/clang5  77.0ns ± 0%   37.0ns ± 0%  -51.95%  (p=0.029 n=4+4)
wuffs_strconv_parse_number_f64_1_lsh53_add1/clang5   690ns ± 0%    725ns ± 2%   +4.95%  (p=0.008 n=5+5)
wuffs_strconv_parse_number_f64_pi_long/clang5       92.0ns ± 0%  136.0ns ± 2%  +47.83%  (p=0.016 n=4+5)
wuffs_strconv_parse_number_f64_pi_short/clang5      35.0ns ± 3%   18.0ns ± 0%  -48.57%  (p=0.008 n=5+5)
wuffs_strconv_parse_number_f64_1_lsh53_add0/gcc7    67.0ns ± 0%   34.0ns ± 0%  -49.25%  (p=0.000 n=5+4)
wuffs_strconv_parse_number_f64_1_lsh53_add1/gcc7     712ns ± 0%    760ns ± 2%   +6.72%  (p=0.008 n=5+5)
wuffs_strconv_parse_number_f64_pi_long/gcc7         88.4ns ± 1%  116.2ns ± 3%  +31.45%  (p=0.008 n=5+5)
wuffs_strconv_parse_number_f64_pi_short/gcc7        32.6ns ± 2%   21.4ns ± 7%  -34.36%  (p=0.008 n=5+5)
2020-07-07 15:27:51 +10:00
Nigel Tao 1bc98b6035 Fix script/print-mpb-powers-of-10.go with -detail 2020-07-06 17:01:41 +10:00
Nigel Tao 267bfc8176 Deepen parse_number_f64's powers_of_10 table
Deepen means changing the mantissa from 64 bits to 128 bits. We also
adjust the exponent bias, in anticipation of a future commit.

Binary size, before:
22232 gen/lib/c/clang-5.0-dynamic/wuffs-base-f64conv.lo
22408 gen/lib/c/clang-5.0-static/wuffs-base-f64conv.o
23816 gen/lib/c/gcc-dynamic/wuffs-base-f64conv.lo
23816 gen/lib/c/gcc-static/wuffs-base-f64conv.o

After:
27336 gen/lib/c/clang-5.0-dynamic/wuffs-base-f64conv.lo
27528 gen/lib/c/clang-5.0-static/wuffs-base-f64conv.o
28856 gen/lib/c/gcc-dynamic/wuffs-base-f64conv.lo
28856 gen/lib/c/gcc-static/wuffs-base-f64conv.o

$ g++ -O3 script/process-json-numbers.c
$ time ./a.out -parse-number-f64 < citylots.json
Before/After:
real    0m1.432s
real	0m1.421s

citylots.json is from github.com/zemirco/sf-city-lots-json
2020-07-05 19:03:37 +10:00
Nigel Tao 53da68fe4b Refine parse_number_f64's powers_of_10 table
Refine means changing the base-10 exponents from "-348 ..= +340 stepping
by 8" to "-326 ..= +310 stepping by 1".

Binary size, before:
15992 gen/lib/c/clang-5.0-dynamic/wuffs-base-f64conv.lo
16232 gen/lib/c/clang-5.0-static/wuffs-base-f64conv.o
17384 gen/lib/c/gcc-dynamic/wuffs-base-f64conv.lo
17384 gen/lib/c/gcc-static/wuffs-base-f64conv.o

After:
22232 gen/lib/c/clang-5.0-dynamic/wuffs-base-f64conv.lo
22408 gen/lib/c/clang-5.0-static/wuffs-base-f64conv.o
23816 gen/lib/c/gcc-dynamic/wuffs-base-f64conv.lo
23816 gen/lib/c/gcc-static/wuffs-base-f64conv.o

$ g++ -O3 script/process-json-numbers.c
$ time ./a.out -parse-number-f64 < citylots.json
Before/After:
real	0m1.455s
real	0m1.432s

citylots.json is from github.com/zemirco/sf-city-lots-json
2020-07-05 13:58:49 +10:00
Nigel Tao 19b3ce24a3 Optimize high_prec_dec__round_just_enough
name                                                               old time/op  new time/op  delta
wuffs_strconv_render_number_f64_just_enough_fractions/clang5       56.4µs ± 1%  56.3µs ± 1%     ~     (p=1.000 n=5+5)
wuffs_strconv_render_number_f64_just_enough_small_integers/clang5  4.12µs ± 2%  1.00µs ± 1%  -75.65%  (p=0.008 n=5+5)
wuffs_strconv_render_number_f64_just_enough_fractions/gcc7         54.3µs ± 0%  54.2µs ± 0%     ~     (p=0.151 n=5+5)
wuffs_strconv_render_number_f64_just_enough_small_integers/gcc7    4.16µs ± 0%  1.01µs ± 0%  -75.77%  (p=0.000 n=4+5)
2020-07-03 23:44:37 +10:00
Nigel Tao 0eee231ce6 Add script/process-json-numbers.c 2020-07-03 12:48:37 +10:00
Nigel Tao 89ceb9fabc Add wuffs_base__render_number_f64 2020-07-01 12:03:20 +10:00
Nigel Tao f7ea462c00 Fix human-readable vmajor when out of base38 range 2020-04-10 22:44:13 +10:00
Nigel Tao 496e88b6c5 Remove wuffs_base__token__link_prev 2020-04-09 22:11:08 +10:00
Nigel Tao 3385efa7fd Update token debug format for extended tokens 2020-04-02 12:10:10 +11:00
Nigel Tao d587c9e4fa Add medium-precision-binary floating point impl
name                                          old time/op   new time/op   delta

strconv_parse_number_f64_1_lsh53_add0/clang5    218ns ± 1%    100ns ± 0%  -54.13%  (p=0.016 n=5+4)
strconv_parse_number_f64_1_lsh53_add1/clang5    716ns ± 2%    741ns ± 1%   +3.46%  (p=0.008 n=5+5)
strconv_parse_number_f64_pi_long/clang5         438ns ± 2%    153ns ± 1%  -65.19%  (p=0.008 n=5+5)
strconv_parse_number_f64_pi_short/clang5        174ns ± 2%     62ns ± 2%  -64.37%  (p=0.008 n=5+5)

strconv_parse_number_f64_1_lsh53_add0/gcc7      221ns ± 1%     97ns ± 4%  -56.25%  (p=0.008 n=5+5)
strconv_parse_number_f64_1_lsh53_add1/gcc7      742ns ± 1%    757ns ± 0%   +2.02%  (p=0.008 n=5+5)
strconv_parse_number_f64_pi_long/gcc7           477ns ± 1%    151ns ± 3%  -68.40%  (p=0.008 n=5+5)
strconv_parse_number_f64_pi_short/gcc7          191ns ± 1%     55ns ± 0%  -71.14%  (p=0.000 n=5+4)
2020-03-31 22:18:54 +11:00
Nigel Tao c0bd9df978 Have script/*.c global var names start with g_ 2020-03-26 21:55:44 +11:00
Nigel Tao f3146c2ea9 Add base.token_decoder.workbuf_len 2020-03-26 08:47:42 +11:00
Nigel Tao 3bfed6d812 Rename std/json quirk_replace_invalid_utf_8 2020-03-24 17:44:47 +11:00
Nigel Tao 5d5a17cc9c Add test/data/json-quirks.json 2020-03-24 17:13:07 +11:00
Nigel Tao a3827275c0 Add std/json quirks 2020-03-12 16:47:26 +11:00
Nigel Tao 499ca132f6 Add wuffs_base__parse_number_f64 2020-03-11 11:41:32 +11:00
Nigel Tao fdac24a425 Rename FOO_BUFFER_SIZE to FOO_BUFFER_ARRAY_SIZE 2020-03-06 21:53:08 +11:00
Nigel Tao 6892095998 Have C programs handle flags consistently 2020-03-03 11:25:18 +11:00
Nigel Tao 6b29f32564 Add script/print-json-token-debug-format.c -a flag 2020-02-29 17:05:24 +11:00
Nigel Tao 85fba7f82b Tweak wuffs_base__token bitmask assignments again 2020-02-29 16:28:06 +11:00
Nigel Tao 67f00c15db Add script/print-json-token-debug-format.c -h flag 2020-02-29 16:13:11 +11:00
Nigel Tao d1c928a1ed Have tokens include explicit link bits 2020-02-29 10:46:44 +11:00