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)
----
diff --git a/lang/builtin/builtin.go b/lang/builtin/builtin.go
index 5f7c32e..c78a386 100644
--- a/lang/builtin/builtin.go
+++ b/lang/builtin/builtin.go
@@ -34,7 +34,6 @@
var Statuses = [...]string{
// Notes.
- `"@I/O redirect"`,
`"@end of data"`,
`"@metadata reported"`,
diff --git a/release/c/wuffs-unsupported-snapshot.c b/release/c/wuffs-unsupported-snapshot.c
index fe09112..13153a5 100644
--- a/release/c/wuffs-unsupported-snapshot.c
+++ b/release/c/wuffs-unsupported-snapshot.c
@@ -189,7 +189,6 @@
} wuffs_base__status;
-extern const char* wuffs_base__note__i_o_redirect;
extern const char* wuffs_base__note__end_of_data;
extern const char* wuffs_base__note__metadata_reported;
extern const char* wuffs_base__suspension__even_more_information;
@@ -7967,7 +7966,6 @@
0x08, 0x0A, 0x0C, 0x10, 0x18, 0x20, 0x30, 0x40,
};
-const char* wuffs_base__note__i_o_redirect = "@base: I/O redirect";
const char* wuffs_base__note__end_of_data = "@base: end of data";
const char* wuffs_base__note__metadata_reported = "@base: metadata reported";
const char* wuffs_base__suspension__even_more_information =