WIFF代码中的C编译器性能迷惑

2020-06-25 05:12:15

永久链接浏览文件此提交将删除`const char*wuff_base__note__i_o_redirect`全局变量的定义。这个变量没有在任何地方使用(在前一次COMMIT删除了对它的引用之后)。删除这一行代码(如果算上声明,就是两行,而不仅仅是定义)可能会对看似无关的性能微基准产生巨大影响。一些数字变得更好(例如+5%),一些数字变得更差(例如-10%)。同一个微基准在一个C编译器上速度更快,而在另一个C编译器上速度更慢,这是一个谜。这个小的、自包含的提交(以及设置它的前一个提交)将立即被回滚,但无论如何它都会被提交,以便我们可以引用git日志中的枚举。要复制:-$GIT CLONE https://github.com/google/wuffs.git$cd wuff$GCC--VERSION|HEAD-n 1gcc(Ubuntu 7.5.0-3ubuntu1~18.04)7.5.0$#检查父提交。$git签出--关闭此提交^$GCC-O3-WALL-std=C99测试/c/std/json.c-dwudfs_mimic$。/a.out-bench-ocus=wuff_。gcc7 1000000 1000000 1125 ns/op 756.762 MB/sBenchmarkwuff_json_decode_1k/gcc7 1000000 1131 ns/s Benchmarkwuff_json_decode_1k/gcc7 1000000 1131 ns/op 752.785 MB/s Benchmarkwuff_json_decode_1k/gcc7 1000000 1131 ns/op 752.697 MB/s Benchmarkwuff_json_decode_1k/gcc7 Benchmarkwuff_json_decode_1k/s。std/json.c-DWUFFS_MIMIC$./a.out-bench-ocus=wuff_json_decode_1k|grep MB/s Benchmarkwuff_json_decode_1k/gcc7 1000000 1200 ns/op 709.617 MB/s Benchmarkwuff_json_decode_1k/gcc7 1000000 1203 ns/op 707.651 MB/s Benchmarkwuff_json_decode_1k/g。-std=C99";还会更改数字。$#签出父提交。$git签出--使_HASH_of_this_Commit^$GCC-O3-WALL测试静默/c/std/json.c-DWUFFS_MIMIC$./a.out-bench-ocus=wuff_json_decode_1k|grep MB/s Benchmarkwuff_json_decode_1k/gc7 1000000 1229 ns/op 693.226 MB/s Benchmarkwc7。MB/s基准标记wuff_json_decode_1k/gcc7 1000000 1234 ns/op 689.986 MB/s Benchmarkwuff_json_decode_1k/gcc7 1000000 1232 ns/op 691.480 MB/s$#检查此提交。$git签出--关闭_hash_of_this_Commit$GCC-O3-WALL测试/c/std/json.c-DWUFFS_MIMIC$。/a.out-bench。json_decode_1k/gcc7 1000000 1131 ns/op 752.849 MB/s Benchmarkwuff_json_decode_1k/gcc7 1000000 1135 ns/op 750.622 MB/s Benchmarkwuff_json_decode_1k/gcc7 1000000 1150 ns/op 740.731 MB/s Benchmarkwuff_json_decode_1k/gcc7 1000000 1135 ns/op 750.609 MB/s$ldd。/a.out。/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/libdso.6。/lib/x86_64-linux-gnu/libpthread.so.0(0x00007f9b4674c000)/lib64/ld-linux-x86-64.so.2(0x00007f9b5b59a000)$rm a.out-在此提交之前/之后还有一些基准数字:-name old Speed new Speed deltawuff_deflate_decode_1k_full_init/clang5 10。%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)wuff_。DEFLATE_DECODE_100K_MAND_BIG_READS/clang5 149MB/s±0%149MB/s±1%-0.56%(p=0.000 n=10+9)wuff_DEFACE_DECODE_1k_FULL_INIT/gcc7 104MB/s±1%102MB/s±1%-2.45%(p=0.000 n=9+10)wuff_DEFATE_DECODE_1k_part_init/gcc7。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.000%158MB/s±0%+2.45%(p=0.000 n=9+10)wuff_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)wuff_gif_decode_10k_bgra/clang5 463MB/s±1%455MB/s