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
54e20636e8
Refactor f64conv's wuffs_base__parse_number_f64
...
Binary size, before:
27704 gen/lib/c/clang-5.0-dynamic/wuffs-base-f64conv.lo
27896 gen/lib/c/clang-5.0-static/wuffs-base-f64conv.o
29120 gen/lib/c/gcc-dynamic/wuffs-base-f64conv.lo
29120 gen/lib/c/gcc-static/wuffs-base-f64conv.o
After:
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
$ g++ -O3 script/process-json-numbers.c
$ time ./a.out -parse-number-f64 < citylots.json
Before/After:
real 0m1.306s
real 0m1.231s
citylots.json is from github.com/zemirco/sf-city-lots-json
name old time/op new time/op delta
wuffs_strconv_parse_number_f64_1_lsh53_add0/clang5 73.2ns ± 2% 77.0ns ± 0% +5.19% (p=0.016 n=5+4)
wuffs_strconv_parse_number_f64_1_lsh53_add1/clang5 688ns ± 0% 690ns ± 0% ~ (p=0.079 n=5+5)
wuffs_strconv_parse_number_f64_pi_long/clang5 113ns ± 1% 92ns ± 0% -18.44% (p=0.000 n=5+4)
wuffs_strconv_parse_number_f64_pi_short/clang5 35.4ns ± 7% 35.0ns ± 3% ~ (p=1.000 n=5+5)
wuffs_strconv_parse_number_f64_1_lsh53_add0/gcc7 67.0ns ± 0% 67.0ns ± 0% ~ (all equal)
wuffs_strconv_parse_number_f64_1_lsh53_add1/gcc7 721ns ± 0% 712ns ± 0% -1.30% (p=0.008 n=5+5)
wuffs_strconv_parse_number_f64_pi_long/gcc7 90.4ns ± 1% 88.4ns ± 1% -2.21% (p=0.008 n=5+5)
wuffs_strconv_parse_number_f64_pi_short/gcc7 32.2ns ± 6% 32.6ns ± 2% ~ (p=0.730 n=5+5)
2020-07-06 11:45:51 +10:00
Nigel Tao
177aa7f0c6
Optimize f64conv's high_prec_dec__parse
...
Binary size, before:
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
After:
27704 gen/lib/c/clang-5.0-dynamic/wuffs-base-f64conv.lo
27896 gen/lib/c/clang-5.0-static/wuffs-base-f64conv.o
29120 gen/lib/c/gcc-dynamic/wuffs-base-f64conv.lo
29120 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.421s
real 0m1.306s
citylots.json is from github.com/zemirco/sf-city-lots-json
name old time/op new time/op delta
wuffs_strconv_parse_number_f64_1_lsh53_add0/clang5 99.0ns ± 0% 73.2ns ± 2% -26.06% (p=0.000 n=4+5)
wuffs_strconv_parse_number_f64_1_lsh53_add1/clang5 744ns ± 1% 688ns ± 0% -7.42% (p=0.008 n=5+5)
wuffs_strconv_parse_number_f64_pi_long/clang5 161ns ± 0% 113ns ± 1% -29.76% (p=0.008 n=5+5)
wuffs_strconv_parse_number_f64_pi_short/clang5 48.0ns ± 0% 35.4ns ± 7% -26.25% (p=0.016 n=4+5)
wuffs_strconv_parse_number_f64_1_lsh53_add0/gcc7 94.8ns ± 1% 67.0ns ± 0% -29.32% (p=0.000 n=5+4)
wuffs_strconv_parse_number_f64_1_lsh53_add1/gcc7 747ns ± 1% 721ns ± 0% -3.51% (p=0.008 n=5+5)
wuffs_strconv_parse_number_f64_pi_long/gcc7 161ns ± 0% 90ns ± 1% -43.99% (p=0.008 n=5+5)
wuffs_strconv_parse_number_f64_pi_short/gcc7 48.4ns ± 5% 32.2ns ± 6% -33.47% (p=0.008 n=5+5)
2020-07-06 11:14:35 +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
fc1b33a0ff
Remove redundant if in MPB__parse_number_f64
2020-07-03 23:47:51 +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
58678cb342
Add wuffs_base__render_number_f64 benches
2020-07-03 23:16:53 +10:00
Nigel Tao
b9afc26387
Add TOKEN__VBD__STRING__CHAIN_ETC
2020-07-03 13:36:13 +10:00
Nigel Tao
0eee231ce6
Add script/process-json-numbers.c
2020-07-03 12:48:37 +10:00
Nigel Tao
a6031b6d2e
Add wuffs_base__utf_8__next_from_end
2020-07-02 15:08:54 +10:00
Nigel Tao
991e1b2667
wuffs gen -version=0.3.0-alpha.5
2020-07-01 12:22:17 +10:00
Nigel Tao
c94ccef400
Make status and vtable names arrays-of-char
...
Binary size, before:
176288 gen/lib/c/clang-5.0-dynamic/libwuffs.so
6216 gen/lib/c/clang-5.0-dynamic/wuffs-base-core.lo
216480 gen/lib/c/clang-5.0-static/libwuffs.a
6144 gen/lib/c/clang-5.0-static/wuffs-base-core.o
196568 gen/lib/c/gcc-dynamic/libwuffs.so
6736 gen/lib/c/gcc-dynamic/wuffs-base-core.lo
246432 gen/lib/c/gcc-static/libwuffs.a
6736 gen/lib/c/gcc-static/wuffs-base-core.o
After:
172192 gen/lib/c/clang-5.0-dynamic/libwuffs.so
5192 gen/lib/c/clang-5.0-dynamic/wuffs-base-core.lo
214400 gen/lib/c/clang-5.0-static/libwuffs.a
5192 gen/lib/c/clang-5.0-static/wuffs-base-core.o
192472 gen/lib/c/gcc-dynamic/libwuffs.so
5656 gen/lib/c/gcc-dynamic/wuffs-base-core.lo
240752 gen/lib/c/gcc-static/libwuffs.a
5656 gen/lib/c/gcc-static/wuffs-base-core.o
2020-07-01 12:16:14 +10:00
Nigel Tao
89ceb9fabc
Add wuffs_base__render_number_f64
2020-07-01 12:03:20 +10:00
Nigel Tao
03f85920be
Make render_number_etc conversions explicit
2020-06-22 13:56:57 +10:00
Nigel Tao
ec5200cb99
Make status and vtable names const pointers
2020-06-22 13:52:29 +10:00
Nigel Tao
668e92cb81
Spin out base-utf8 sub-module
...
Before:
8224 gen/lib/c/clang-5.0-dynamic/wuffs-base-core.lo
8200 gen/lib/c/clang-5.0-static/wuffs-base-core.o
8704 gen/lib/c/gcc-dynamic/wuffs-base-core.lo
8920 gen/lib/c/gcc-static/wuffs-base-core.o
After:
6216 gen/lib/c/clang-5.0-dynamic/wuffs-base-core.lo
2736 gen/lib/c/clang-5.0-dynamic/wuffs-base-utf8.lo
6216 gen/lib/c/clang-5.0-static/wuffs-base-core.o
2712 gen/lib/c/clang-5.0-static/wuffs-base-utf8.o
6728 gen/lib/c/gcc-dynamic/wuffs-base-core.lo
3008 gen/lib/c/gcc-dynamic/wuffs-base-utf8.lo
6728 gen/lib/c/gcc-static/wuffs-base-core.o
3224 gen/lib/c/gcc-static/wuffs-base-utf8.o
2020-06-22 13:40:03 +10:00
Nigel Tao
22a09b4133
Spin out base-i64conv sub-module
...
Before:
12624 gen/lib/c/clang-5.0-dynamic/wuffs-base-core.lo
13032 gen/lib/c/clang-5.0-static/wuffs-base-core.o
12184 gen/lib/c/gcc-dynamic/wuffs-base-core.lo
12408 gen/lib/c/gcc-static/wuffs-base-core.o
After:
8224 gen/lib/c/clang-5.0-dynamic/wuffs-base-core.lo
5608 gen/lib/c/clang-5.0-dynamic/wuffs-base-i64conv.lo
8200 gen/lib/c/clang-5.0-static/wuffs-base-core.o
6032 gen/lib/c/clang-5.0-static/wuffs-base-i64conv.o
8704 gen/lib/c/gcc-dynamic/wuffs-base-core.lo
4952 gen/lib/c/gcc-dynamic/wuffs-base-i64conv.lo
8920 gen/lib/c/gcc-static/wuffs-base-core.o
4912 gen/lib/c/gcc-static/wuffs-base-i64conv.o
2020-06-21 22:17:42 +10:00
Nigel Tao
f5fbc5d8e7
Rename initialize_flags argument
2020-06-21 22:02:20 +10:00
Nigel Tao
d40a386211
Add wuffs_base__render_number_{i,u}64
2020-06-21 21:57:48 +10:00
Nigel Tao
00cc8a50aa
wuffs gen -version=0.3.0-alpha.4
2020-06-17 21:27:28 +10:00
Nigel Tao
d377dcaea8
Don't use #warning (a GCC notion) with MSVC
2020-06-17 21:24:14 +10:00
Nigel Tao
824b87bb86
Roll back cb198413 re MSVC __cplusplus macro
...
Commit cb19841358 "Work around MSVC's
__cplusplus regarding C++11" did not fix compiler errors with older MSVC
versions as hoped.
2020-06-17 21:18:36 +10:00
Nigel Tao
025f9c208e
Roll back 196920ee unique_ptr constructors
...
Commit 196920ee91 "Spell out
std::unique_ptr constructor calls" did not fix compiler errors with
older MSVC versions as hoped.
2020-06-17 21:12:07 +10:00
Nigel Tao
a7418b76fc
wuffs gen -version=0.3.0-alpha.3
2020-06-17 15:57:23 +10:00
Nigel Tao
196920ee91
Spell out std::unique_ptr constructor calls
2020-06-17 15:56:46 +10:00
Nigel Tao
c8026c91ff
wuffs gen -version=0.3.0-alpha.2
2020-06-17 06:46:00 +10:00
Nigel Tao
cb19841358
Work around MSVC's __cplusplus regarding C++11
2020-06-17 06:39:45 +10:00
Nigel Tao
635b502649
Tweak lib/dumbindent's comments
2020-06-16 22:34:36 +10:00
Nigel Tao
ab580e7696
Add more comments on wuffsfmt's -l and -w flags
2020-06-16 14:27:13 +10:00
Nigel Tao
c9b50c0be7
Add links to dumbindent blog post
2020-06-16 14:25:46 +10:00
Nigel Tao
c29853ffef
Add links to other convert-to-nia implementations
2020-06-16 14:24:00 +10:00
Nigel Tao
30793928d0
wuffs gen -version=0.3.0-alpha.1
2020-06-11 23:02:02 +10:00
Nigel Tao
533b84b3b1
Simplify WUFFS_VERSION_ETC macros
2020-06-11 23:01:50 +10:00
Nigel Tao
82233fe06c
Fix dumbindent comment typo
2020-06-10 22:52:49 +10:00
Nigel Tao
f89d2ef4ab
Update doc/note/auto-formatting.md comparison link
2020-06-10 22:43:51 +10:00
Nigel Tao
f935120aa6
Tweak how dumbindent handles #preproc lines
2020-06-10 22:37:54 +10:00
Nigel Tao
b1ea22045a
Stop dumbindent adding or removing line breaks
2020-06-10 21:51:25 +10:00
Nigel Tao
b82396a3c6
Stop dumbindent dropping blank lines near braces
2020-06-10 21:06:06 +10:00
Nigel Tao
58c0862c50
Stop dumbindent collapsing consecutive blank lines
2020-06-10 12:22:41 +10:00
Nigel Tao
ed48514f30
Remove ast.NewExpr statusPkg arg
2020-06-10 12:05:48 +10:00
Nigel Tao
7dc73a856a
Remove unused checker.exprConstValue method
2020-06-10 11:43:46 +10:00
Nigel Tao
74d291453d
Un-special-case parsing base."etc"
2020-06-10 11:34:56 +10:00
Nigel Tao
4e2d0c1e5f
Cgen explicit type cast for (CONSTANT >> x)
2020-06-10 10:32:13 +10:00
Nigel Tao
66b0a12b6c
Add json.EXPECT_ETC constants
2020-06-09 23:50:35 +10:00
Nigel Tao
3d31ac03eb
Add base.TOKEN__ETC constants
2020-06-09 23:34:42 +10:00
Nigel Tao
8bd30e912c
Tweak dumbindent.breakAfterBrace
2020-06-09 22:45:40 +10:00
Nigel Tao
63c12cad17
Have dumbindent catch "namespace foo {".
2020-06-09 22:08:39 +10:00
Nigel Tao
3b1d3d0a39
Remove check.Error.OtherFoo fields
2020-06-09 17:00:24 +10:00
Nigel Tao
6f43ab4b92
Reject duplicate top level names
2020-06-09 16:59:43 +10:00
Nigel Tao
1dae694e00
Update doc/note/auto-formatting.md comparison link
2020-06-09 15:59:46 +10:00
Nigel Tao
8bf4084c8b
Update dumbindent comparison for clang-format-9
...
The numbers are the median real time of 5 runs.
2020-06-09 15:46:56 +10:00
Nigel Tao
7e32336de0
Add base.PIXEL_FORMAT__ETC constants
2020-06-09 12:34:34 +10:00
Nigel Tao
983c5cd90e
Update doc/note/auto-formatting.md comparison link
2020-06-08 23:29:52 +10:00
Nigel Tao
22d08366c8
Add dumbindent algorithm comment
2020-06-08 23:25:08 +10:00
Nigel Tao
e42d126667
Update doc/note/auto-formatting.md comparison link
2020-06-07 22:02:07 +10:00
Nigel Tao
2858c4cfc2
Add dumbindent.Options (tabs vs spaces)
2020-06-07 21:59:53 +10:00
Nigel Tao
53d5f5155c
Have dumbindent break after some '{' and ';'s
2020-06-07 21:52:24 +10:00
Nigel Tao
709e169955
Have cgen line-break some long expressions
2020-06-07 10:12:47 +10:00
Nigel Tao
60cd231e65
Update doc/note/auto-formatting.md comparison link
2020-06-06 22:45:57 +10:00
Nigel Tao
7b6ce4a595
Remove dumbindent debugging code
2020-06-06 22:41:15 +10:00
Nigel Tao
0ad5f9b617
Have dumbindent no longer treat labels specially
2020-06-06 22:38:29 +10:00
Nigel Tao
6424bae087
Have dumbindent handle multi-line strings/comments
...
Fixes #31
2020-06-06 22:32:39 +10:00
Nigel Tao
3d7af06727
Have dumbindent take a dst slice argument
2020-06-06 21:09:41 +10:00
Nigel Tao
dd04d55417
Update dumbindent comparison for clang-format-9
2020-06-05 18:35:05 +10:00
Nigel Tao
f45f01f4f3
Update clang-format from v5 to v9
2020-06-05 14:06:56 +10:00
Nigel Tao
d48a4eb581
Add dumbindent comment about extern "C"
2020-06-05 13:26:32 +10:00
Nigel Tao
78daf1ca91
Update doc/note/auto-formatting.md for dumbindent
2020-06-05 10:59:27 +10:00
Nigel Tao
a0f7059eeb
Tweak changelog bullet for C formatting
2020-06-05 10:46:42 +10:00
Nigel Tao
527a9ac984
Spin out an internal/cgen/data directory
...
Grepping in internal/cgen/*.go will no longer also grep in the generated
data.go file.
2020-06-05 10:36:17 +10:00
Nigel Tao
d0dec081a6
Tweak cgen+dumbindent output
2020-06-05 10:22:14 +10:00
Nigel Tao
d5d4da0ab6
Add some "// --------" section-break comments
2020-06-05 00:10:31 +10:00
Nigel Tao
8cd39fc1dd
Remove -cformatter flag
2020-06-05 00:08:05 +10:00
Nigel Tao
12b0f4c0bc
Change the default -cformatter to dumbindent
...
A follow-up commit will remove the -cformatter flag entirely.
Formatting the generated C code is now a small fraction of where "wuffs
gen" spends its time.
----
$ # Before.
$ time wuffs gen > /dev/null
real 0m0.932s
user 0m0.837s
sys 0m0.187s
$ # After.
$ time wuffs gen > /dev/null
real 0m0.186s
user 0m0.170s
sys 0m0.069s
$ time wuffs gen -cformatter= > /dev/null
real 0m0.184s
user 0m0.170s
sys 0m0.059s
----
2020-06-04 23:59:20 +10:00
Nigel Tao
d8cd72798a
Add {cmd,lib}/dumbindent
2020-06-04 23:35:11 +10:00
Nigel Tao
b2dc84105a
Clean up more wuffs-c output (before clang-format)
2020-06-04 23:26:15 +10:00
Nigel Tao
58a48d5a54
Don't run the base package through the C-formatter
...
----
$ # Before.
$ time wuffs gen > /dev/null
real 0m1.427s
user 0m1.272s
sys 0m0.245s
$ # After.
$ time wuffs gen > /dev/null
real 0m0.953s
user 0m0.864s
sys 0m0.188s
----
2020-06-03 23:31:54 +10:00
Nigel Tao
4402c1c7c0
Clean up more wuffs-c output (before clang-format)
2020-06-03 23:14:55 +10:00
Nigel Tao
3efb204f4e
Drop wuffs-c genrelease's exec of the C-formatter
...
genrelease essentially concatenates the individual packages' generated C
files, which should already be formatted.
----
$ # Before.
$ time wuffs gen > /dev/null
real 0m2.622s
user 0m2.457s
sys 0m0.266s
$ # After.
$ time wuffs gen > /dev/null
real 0m1.433s
user 0m1.335s
sys 0m0.191s
----
2020-06-03 13:46:24 +10:00
Nigel Tao
16c1f3cfd7
Clean up some wuffs-c output (before clang-format)
2020-06-03 13:36:04 +10:00
Nigel Tao
ddc8973ef0
Let wuffs-c take a no-op C formatter
...
Reinforcing the previous commit's (e5cc4a42 ) observation, over 93% of
compilation time (converting foo.wuffs into foo.c) is spent piping the
generated C code through clang-format.
----
$ time wuffs gen -cformatter=clang-format-5.0 > /dev/null
real 0m2.855s
user 0m2.680s
sys 0m0.286s
$ time wuffs gen -cformatter= > /dev/null
real 0m0.175s
user 0m0.172s
sys 0m0.050s
----
2020-06-03 13:21:53 +10:00
Nigel Tao
e5cc4a42e4
Measure how much of "wuffs gen" is clang-format
...
----
$ time wuffs gen
1 milliseconds generating the C code
753 milliseconds formatting the C code via "clang-format-5.0"
gen unchanged: /etcetera/wuffs/gen/c/wuffs-base.c
0 milliseconds generating the C code
19 milliseconds formatting the C code via "clang-format-5.0"
gen unchanged: /etcetera/wuffs/gen/c/wuffs-std-adler32.c
gen unchanged: /etcetera/wuffs/gen/wuffs/std/adler32.wuffs
1 milliseconds generating the C code
61 milliseconds formatting the C code via "clang-format-5.0"
gen unchanged: /etcetera/wuffs/gen/c/wuffs-std-bmp.c
gen unchanged: /etcetera/wuffs/gen/wuffs/std/bmp.wuffs
1 milliseconds generating the C code
78 milliseconds formatting the C code via "clang-format-5.0"
gen unchanged: /etcetera/wuffs/gen/c/wuffs-std-crc32.c
gen unchanged: /etcetera/wuffs/gen/wuffs/std/crc32.wuffs
2 milliseconds generating the C code
93 milliseconds formatting the C code via "clang-format-5.0"
gen unchanged: /etcetera/wuffs/gen/c/wuffs-std-deflate.c
gen unchanged: /etcetera/wuffs/gen/wuffs/std/deflate.wuffs
0 milliseconds generating the C code
34 milliseconds formatting the C code via "clang-format-5.0"
gen unchanged: /etcetera/wuffs/gen/c/wuffs-std-lzw.c
gen unchanged: /etcetera/wuffs/gen/wuffs/std/lzw.wuffs
4 milliseconds generating the C code
203 milliseconds formatting the C code via "clang-format-5.0"
gen unchanged: /etcetera/wuffs/gen/c/wuffs-std-gif.c
gen unchanged: /etcetera/wuffs/gen/wuffs/std/gif.wuffs
0 milliseconds generating the C code
33 milliseconds formatting the C code via "clang-format-5.0"
gen unchanged: /etcetera/wuffs/gen/c/wuffs-std-gzip.c
gen unchanged: /etcetera/wuffs/gen/wuffs/std/gzip.wuffs
4 milliseconds generating the C code
135 milliseconds formatting the C code via "clang-format-5.0"
gen unchanged: /etcetera/wuffs/gen/c/wuffs-std-json.c
gen unchanged: /etcetera/wuffs/gen/wuffs/std/json.wuffs
0 milliseconds generating the C code
44 milliseconds formatting the C code via "clang-format-5.0"
gen unchanged: /etcetera/wuffs/gen/c/wuffs-std-wbmp.c
gen unchanged: /etcetera/wuffs/gen/wuffs/std/wbmp.wuffs
0 milliseconds generating the C code
32 milliseconds formatting the C code via "clang-format-5.0"
gen unchanged: /etcetera/wuffs/gen/c/wuffs-std-zlib.c
gen unchanged: /etcetera/wuffs/gen/wuffs/std/zlib.wuffs
3 milliseconds collecting the C code
1173 milliseconds formatting the C code via "clang-format-5.0"
gen unchanged: /etcetera/wuffs/release/c/wuffs-unsupported-snapshot.c
real 0m2.849s
user 0m2.674s
sys 0m0.278s
----
2020-06-03 12:30:47 +10:00
Nigel Tao
71528b33dd
Rename frame_config.update to frame_config.set
2020-06-03 11:34:57 +10:00
Nigel Tao
6c83516afa
Ensure that you cannot return a suspension
2020-06-03 11:08:23 +10:00
Nigel Tao
ed9025c8dd
Make swizzle_etc_reader sign conversion explicit
2020-06-02 23:29:42 +10:00
Nigel Tao
f73fc7721a
Replace wuffs_base__make_status(x).repr with x
2020-06-02 23:25:47 +10:00
Nigel Tao
de1e274ad2
Remove io_reader.take
2020-06-02 23:08:24 +10:00
Nigel Tao
8b21a7600a
Add swizzle_interleaved_from_reader
2020-06-02 23:04:22 +10:00
Nigel Tao
d7c9e9bbc9
De-duplicate the wuffs_gif_decode test function
2020-06-01 14:33:19 +10:00
Nigel Tao
e6b7c51557
Inline do_bench_gif_decode
2020-06-01 14:23:59 +10:00
Nigel Tao
829519880a
Drop unnecessary memcpy in do_bench_image_decode
...
This doesn't affect the std/bmp or std/gif implementations per se, only
the code that benches them. Prior to this commit, the source file was
first decoded into a pixel buffer and then always copied from the
(2-dimensional) wuffs_base__pixel_buffer to a (1-dimensional)
wuffs_base_io_buffer. That copy is useful for *tests*, which compare
that io_buffer's contents to a known good result (i.e. a separate I/O
buffer filled with the contents of a golden file), but it isn't
necessary for *benches*. Dropping that unnecessary copy reduces the
total time per iteration, and therefore increases the reported speed.
name old speed new speed delta
wuffs_bmp_decode_40k/clang5 2.09GB/s ± 2% 2.48GB/s ± 0% +18.78% (p=0.008 n=5+5)
wuffs_bmp_decode_40k/gcc7 1.73GB/s ± 1% 1.93GB/s ± 0% +11.54% (p=0.008 n=5+5)
wuffs_gif_decode_1k_bw/clang5 291MB/s ± 0% 376MB/s ± 1% +29.14% (p=0.008 n=5+5)
wuffs_gif_decode_1k_color_full_init/clang5 95.3MB/s ± 1% 103.2MB/s ± 1% +8.37% (p=0.008 n=5+5)
wuffs_gif_decode_1k_color_part_init/clang5 117MB/s ± 0% 130MB/s ± 0% +10.68% (p=0.008 n=5+5)
wuffs_gif_decode_10k_bgra/clang5 469MB/s ± 0% 489MB/s ± 1% +4.39% (p=0.008 n=5+5)
wuffs_gif_decode_10k_indexed/clang5 126MB/s ± 1% 130MB/s ± 1% +3.50% (p=0.008 n=5+5)
wuffs_gif_decode_20k/clang5 152MB/s ± 0% 156MB/s ± 1% +2.77% (p=0.008 n=5+5)
wuffs_gif_decode_100k_artificial/clang5 318MB/s ± 0% 329MB/s ± 0% +3.53% (p=0.008 n=5+5)
wuffs_gif_decode_100k_realistic/clang5 137MB/s ± 0% 139MB/s ± 0% +1.40% (p=0.008 n=5+5)
wuffs_gif_decode_1000k_full_init/clang5 138MB/s ± 0% 140MB/s ± 1% +1.45% (p=0.008 n=5+5)
wuffs_gif_decode_1000k_part_init/clang5 139MB/s ± 0% 140MB/s ± 1% +1.03% (p=0.008 n=5+5)
wuffs_gif_decode_anim_screencap/clang5 661MB/s ± 0% 747MB/s ± 1% +13.08% (p=0.008 n=5+5)
mimic_gif_decode_1k_bw/clang5 92.0MB/s ± 0% 91.9MB/s ± 1% ~ (p=0.841 n=5+5)
mimic_gif_decode_1k_color/clang5 45.5MB/s ± 0% 45.7MB/s ± 0% +0.45% (p=0.032 n=5+4)
mimic_gif_decode_10k_indexed/clang5 53.5MB/s ± 0% 53.7MB/s ± 0% +0.31% (p=0.032 n=5+4)
mimic_gif_decode_20k/clang5 55.5MB/s ± 0% 55.1MB/s ± 2% ~ (p=0.690 n=5+5)
mimic_gif_decode_100k_artificial/clang5 88.8MB/s ± 0% 89.0MB/s ± 1% ~ (p=0.151 n=5+5)
mimic_gif_decode_100k_realistic/clang5 53.5MB/s ± 1% 53.7MB/s ± 0% +0.31% (p=0.024 n=5+5)
mimic_gif_decode_1000k/clang5 54.6MB/s ± 0% 54.6MB/s ± 1% ~ (p=0.222 n=5+5)
mimic_gif_decode_anim_screencap/clang5 106MB/s ± 0% 109MB/s ± 0% +2.59% (p=0.008 n=5+5)
wuffs_gif_decode_1k_bw/gcc7 284MB/s ± 0% 356MB/s ± 0% +25.33% (p=0.016 n=4+5)
wuffs_gif_decode_1k_color_full_init/gcc7 82.1MB/s ± 0% 95.3MB/s ± 0% +16.08% (p=0.008 n=5+5)
wuffs_gif_decode_1k_color_part_init/gcc7 97.5MB/s ± 0% 117.4MB/s ± 0% +20.39% (p=0.008 n=5+5)
wuffs_gif_decode_10k_bgra/gcc7 345MB/s ± 0% 396MB/s ± 0% +14.71% (p=0.016 n=4+5)
wuffs_gif_decode_10k_indexed/gcc7 104MB/s ± 0% 121MB/s ± 0% +16.38% (p=0.008 n=5+5)
wuffs_gif_decode_20k/gcc7 131MB/s ± 0% 149MB/s ± 0% +13.55% (p=0.008 n=5+5)
wuffs_gif_decode_100k_artificial/gcc7 293MB/s ± 0% 321MB/s ± 1% +9.77% (p=0.008 n=5+5)
wuffs_gif_decode_100k_realistic/gcc7 116MB/s ± 1% 130MB/s ± 1% +12.10% (p=0.008 n=5+5)
wuffs_gif_decode_1000k_full_init/gcc7 117MB/s ± 1% 132MB/s ± 1% +12.53% (p=0.008 n=5+5)
wuffs_gif_decode_1000k_part_init/gcc7 117MB/s ± 0% 132MB/s ± 1% +12.20% (p=0.008 n=5+5)
wuffs_gif_decode_anim_screencap/gcc7 615MB/s ± 2% 711MB/s ± 2% +15.53% (p=0.008 n=5+5)
mimic_gif_decode_1k_bw/gcc7 91.4MB/s ± 0% 91.7MB/s ± 1% ~ (p=0.095 n=5+5)
mimic_gif_decode_1k_color/gcc7 46.3MB/s ± 0% 46.2MB/s ± 2% ~ (p=0.841 n=5+5)
mimic_gif_decode_10k_indexed/gcc7 51.9MB/s ± 1% 51.7MB/s ± 1% ~ (p=0.310 n=5+5)
mimic_gif_decode_20k/gcc7 54.2MB/s ± 0% 54.2MB/s ± 1% ~ (p=0.421 n=5+5)
mimic_gif_decode_100k_artificial/gcc7 88.4MB/s ± 1% 88.7MB/s ± 1% ~ (p=0.222 n=5+5)
mimic_gif_decode_100k_realistic/gcc7 53.7MB/s ± 0% 53.7MB/s ± 0% ~ (p=0.206 n=5+5)
mimic_gif_decode_1000k/gcc7 53.8MB/s ± 2% 54.0MB/s ± 2% ~ (p=0.690 n=5+5)
mimic_gif_decode_anim_screencap/gcc7 106MB/s ± 0% 109MB/s ± 0% +2.79% (p=0.008 n=5+5)
2020-06-01 13:59:50 +10:00
Nigel Tao
4b9b971436
Harmonize do_bench_{gif,image}_decode
2020-06-01 13:27:46 +10:00
Nigel Tao
2784613b49
Add n_bytes_out arg to gif bench functions
2020-06-01 13:14:14 +10:00
Nigel Tao
7a85f67b22
Add std/bmp benchmark
2020-06-01 13:03:03 +10:00
Nigel Tao
54196c4e80
Rename pixel_swizzler.swizzle_interleaved
2020-05-29 16:54:05 +10:00
Nigel Tao
6537a817b7
Roll back the two previous "@I/O redirect" commits
...
See the previous commit for the rationale.
2020-05-29 11:27:51 +10:00
Nigel Tao
49023afd48
Performance mystery: delete unused string constant
...
This commit deletes the definition of the `const char*
wuffs_base__note__i_o_redirect` global variable. This variable is not
used anywhere (after the previous commit removed references to it).
Deleting this one line of code (two if you count the declaration, not
just the definition) can have a dramatic effect on seemingly unrelated
performance micro-benchmarks. Some numbers get better (e.g. +5%), some
numbers get worse (e.g. -10%). The same micro-benchmark can get faster
on one C compiler but slower on another.
It is a mystery why this happens. This small, self-contained commit (as
well as the previous one, which set it up) will be immediately followed
by a roll back, but it is committed anyway so that we can refer to these
numbers in the git log. To reproduce:
----
$ git clone https://github.com/google/wuffs.git
$ cd wuffs
$ gcc --version | head -n 1
gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
$ # Check out the parent commit.
$ git checkout --quiet THE_HASH_OF_THIS_COMMIT^
$ gcc -O3 -Wall -std=c99 test/c/std/json.c -DWUFFS_MIMIC
$ ./a.out -bench -focus=wuffs_json_decode_1k | grep MB/s
Benchmarkwuffs_json_decode_1k/gcc7 1000000 1125 ns/op 756.762 MB/s
Benchmarkwuffs_json_decode_1k/gcc7 1000000 1131 ns/op 752.652 MB/s
Benchmarkwuffs_json_decode_1k/gcc7 1000000 1131 ns/op 752.785 MB/s
Benchmarkwuffs_json_decode_1k/gcc7 1000000 1131 ns/op 752.697 MB/s
Benchmarkwuffs_json_decode_1k/gcc7 1000000 1132 ns/op 752.365 MB/s
$ # Check out this commit.
$ git checkout --quiet THE_HASH_OF_THIS_COMMIT
$ gcc -O3 -Wall -std=c99 test/c/std/json.c -DWUFFS_MIMIC
$ ./a.out -bench -focus=wuffs_json_decode_1k | grep MB/s
Benchmarkwuffs_json_decode_1k/gcc7 1000000 1200 ns/op 709.617 MB/s
Benchmarkwuffs_json_decode_1k/gcc7 1000000 1203 ns/op 707.651 MB/s
Benchmarkwuffs_json_decode_1k/gcc7 1000000 1203 ns/op 707.976 MB/s
Benchmarkwuffs_json_decode_1k/gcc7 1000000 1233 ns/op 690.663 MB/s
Benchmarkwuffs_json_decode_1k/gcc7 1000000 1203 ns/op 708.153 MB/s
$ # Dropping the "-std=c99" also changes the numbers.
$ # Check out the parent commit.
$ git checkout --quiet THE_HASH_OF_THIS_COMMIT^
$ gcc -O3 -Wall test/c/std/json.c -DWUFFS_MIMIC
$ ./a.out -bench -focus=wuffs_json_decode_1k | grep MB/s
Benchmarkwuffs_json_decode_1k/gcc7 1000000 1229 ns/op 693.226 MB/s
Benchmarkwuffs_json_decode_1k/gcc7 1000000 1230 ns/op 692.254 MB/s
Benchmarkwuffs_json_decode_1k/gcc7 1000000 1230 ns/op 692.486 MB/s
Benchmarkwuffs_json_decode_1k/gcc7 1000000 1234 ns/op 689.986 MB/s
Benchmarkwuffs_json_decode_1k/gcc7 1000000 1232 ns/op 691.480 MB/s
$ # Check out this commit.
$ git checkout --quiet THE_HASH_OF_THIS_COMMIT
$ gcc -O3 -Wall test/c/std/json.c -DWUFFS_MIMIC
$ ./a.out -bench -focus=wuffs_json_decode_1k | grep MB/s
Benchmarkwuffs_json_decode_1k/gcc7 1000000 1129 ns/op 754.103 MB/s
Benchmarkwuffs_json_decode_1k/gcc7 1000000 1131 ns/op 752.849 MB/s
Benchmarkwuffs_json_decode_1k/gcc7 1000000 1135 ns/op 750.622 MB/s
Benchmarkwuffs_json_decode_1k/gcc7 1000000 1150 ns/op 740.731 MB/s
Benchmarkwuffs_json_decode_1k/gcc7 1000000 1135 ns/op 750.609 MB/s
$ ldd ./a.out
linux-vdso.so.1 (0x00007ffd9b1f2000)
libgtk3-nocsd.so.0 => /usr/lib/x86_64-linux-gnu/libgtk3-nocsd.so.0 (0x00007f9b46f60000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f9b46b6f000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f9b4696b000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f9b4674c000)
/lib64/ld-linux-x86-64.so.2 (0x00007f9b5b59a000)
$ rm a.out
----
Some more benchmark numbers before/after this commit:
----
name old speed new speed delta
wuffs_deflate_decode_1k_full_init/clang5 103MB/s ± 1% 105MB/s ± 1% +2.25% (p=0.000 n=9+10)
wuffs_deflate_decode_1k_part_init/clang5 121MB/s ± 0% 122MB/s ± 0% ~ (p=1.000 n=9+9)
wuffs_deflate_decode_10k_full_init/clang5 148MB/s ± 1% 149MB/s ± 0% ~ (p=0.059 n=9+8)
wuffs_deflate_decode_10k_part_init/clang5 151MB/s ± 0% 151MB/s ± 0% ~ (p=0.968 n=9+10)
wuffs_deflate_decode_100k_just_one_read/clang5 172MB/s ± 0% 171MB/s ± 1% -0.44% (p=0.001 n=9+9)
wuffs_deflate_decode_100k_many_big_reads/clang5 149MB/s ± 0% 149MB/s ± 1% -0.56% (p=0.000 n=10+9)
wuffs_deflate_decode_1k_full_init/gcc7 104MB/s ± 1% 102MB/s ± 1% -2.45% (p=0.000 n=9+10)
wuffs_deflate_decode_1k_part_init/gcc7 121MB/s ± 0% 121MB/s ± 0% +0.46% (p=0.000 n=9+10)
wuffs_deflate_decode_10k_full_init/gcc7 147MB/s ± 0% 153MB/s ± 0% +3.75% (p=0.000 n=8+10)
wuffs_deflate_decode_10k_part_init/gcc7 150MB/s ± 1% 155MB/s ± 0% +3.98% (p=0.000 n=9+10)
wuffs_deflate_decode_100k_just_one_read/gcc7 184MB/s ± 0% 194MB/s ± 1% +5.43% (p=0.000 n=9+10)
wuffs_deflate_decode_100k_many_big_reads/gcc7 154MB/s ± 0% 158MB/s ± 0% +2.45% (p=0.000 n=9+10)
wuffs_gif_decode_1k_bw/clang5 281MB/s ± 1% 278MB/s ± 1% -0.92% (p=0.003 n=10+9)
wuffs_gif_decode_1k_color_full_init/clang5 97.8MB/s ± 1% 93.7MB/s ± 3% -4.26% (p=0.000 n=10+10)
wuffs_gif_decode_1k_color_part_init/clang5 117MB/s ± 1% 115MB/s ± 1% -1.41% (p=0.000 n=9+10)
wuffs_gif_decode_10k_bgra/clang5 463MB/s ± 1% 455MB/s ± 1% -1.68% (p=0.000 n=10+10)
wuffs_gif_decode_10k_indexed/clang5 124MB/s ± 1% 121MB/s ± 1% -2.31% (p=0.000 n=9+9)
wuffs_gif_decode_20k/clang5 149MB/s ± 1% 146MB/s ± 1% -1.95% (p=0.000 n=10+10)
wuffs_gif_decode_100k_artificial/clang5 313MB/s ± 1% 307MB/s ± 0% -1.94% (p=0.000 n=9+7)
wuffs_gif_decode_100k_realistic/clang5 135MB/s ± 1% 133MB/s ± 1% -1.18% (p=0.000 n=10+8)
wuffs_gif_decode_1000k_full_init/clang5 136MB/s ± 1% 132MB/s ± 4% -2.27% (p=0.023 n=10+10)
wuffs_gif_decode_1000k_part_init/clang5 136MB/s ± 1% 132MB/s ± 3% -2.96% (p=0.000 n=9+10)
wuffs_gif_decode_anim_screencap/clang5 644MB/s ± 1% 621MB/s ± 3% -3.51% (p=0.000 n=10+10)
wuffs_gif_decode_1k_bw/gcc7 290MB/s ± 1% 287MB/s ± 1% -1.18% (p=0.000 n=10+10)
wuffs_gif_decode_1k_color_full_init/gcc7 91.7MB/s ± 1% 88.2MB/s ± 1% -3.85% (p=0.000 n=10+10)
wuffs_gif_decode_1k_color_part_init/gcc7 107MB/s ± 1% 103MB/s ± 1% -4.12% (p=0.000 n=9+10)
wuffs_gif_decode_10k_bgra/gcc7 370MB/s ± 1% 344MB/s ± 1% -6.98% (p=0.000 n=10+9)
wuffs_gif_decode_10k_indexed/gcc7 113MB/s ± 2% 104MB/s ± 1% -8.31% (p=0.000 n=10+8)
wuffs_gif_decode_20k/gcc7 139MB/s ± 1% 127MB/s ± 3% -8.49% (p=0.000 n=10+10)
wuffs_gif_decode_100k_artificial/gcc7 299MB/s ± 0% 280MB/s ± 1% -6.43% (p=0.000 n=9+8)
wuffs_gif_decode_100k_realistic/gcc7 123MB/s ± 1% 111MB/s ± 1% -10.21% (p=0.000 n=10+8)
wuffs_gif_decode_1000k_full_init/gcc7 124MB/s ± 1% 112MB/s ± 1% -9.34% (p=0.000 n=10+8)
wuffs_gif_decode_1000k_part_init/gcc7 125MB/s ± 1% 112MB/s ± 1% -10.19% (p=0.000 n=10+9)
wuffs_gif_decode_anim_screencap/gcc7 622MB/s ± 1% 599MB/s ± 3% -3.68% (p=0.000 n=9+10)
wuffs_json_decode_1k/clang5 628MB/s ± 1% 628MB/s ± 1% ~ (p=0.842 n=9+10)
wuffs_json_decode_21k_formatted/clang5 331MB/s ± 1% 331MB/s ± 0% ~ (p=0.720 n=10+9)
wuffs_json_decode_26k_compact/clang5 521MB/s ± 1% 521MB/s ± 0% ~ (p=0.549 n=10+9)
wuffs_json_decode_217k_stringy/clang5 432MB/s ± 1% 432MB/s ± 1% ~ (p=0.780 n=10+9)
wuffs_json_decode_1k/gcc7 745MB/s ± 0% 703MB/s ± 0% -5.70% (p=0.000 n=9+10)
wuffs_json_decode_21k_formatted/gcc7 418MB/s ± 1% 400MB/s ± 1% -4.44% (p=0.000 n=10+8)
wuffs_json_decode_26k_compact/gcc7 554MB/s ± 1% 511MB/s ± 1% -7.72% (p=0.000 n=9+10)
wuffs_json_decode_217k_stringy/gcc7 452MB/s ± 1% 422MB/s ± 1% -6.58% (p=0.000 n=9+10)
----
2020-05-29 11:21:32 +10:00
Nigel Tao
844fc9b5ee
Temporarily avoid using base."@I/O redirect"
...
This commit (and the next) will soon be followed by a rollback.
2020-05-29 09:53:30 +10:00
Nigel Tao
302afb7ce5
Add const to wuffs_base__pixel_swizzler__func arg
2020-05-28 00:07:45 +10:00