Skip to content

Commit 4a0ea61

Browse files
siv2rfjahr
authored andcommitted
batch: Generate graphs for batch verification speed up
This commit generates two semi-log graphs that visualize the batch verification speed up over single verification (y-axis) wrt the number of signatures (or tweak checks) in the batch (x-axis). The input data points are taken from the batch verify benchmark. GNU plot was used to generate these graphs (plot.gp file). The instructions to reproduce these graphs (on your local machine) are given in doc/speedup-batch.md file. The value of `STRAUSS_MAX_TERMS_PER_BATCH` was calculated (approx) from the generated graphs. Relevant discussion: siv2r#2 (comment)
1 parent a804f05 commit 4a0ea61

10 files changed

+365
-0
lines changed

doc/speedup-batch.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Schnorrsig Batch Verification Speedup
2+
3+
![Speedup over single verification](speedup-batch/schnorrsig-speedup-batch.png)
4+
5+
# Tweak Pubkey Check Batch Verification Speedup
6+
7+
![Speedup over single verification](speedup-batch/tweakcheck-speedup-batch.png)
8+
9+
Build steps
10+
-----------
11+
To generate the above graphs on your local machine:
12+
13+
$ cd doc/speedup-batch
14+
$ make
15+
$ make speedup-batch.png

doc/speedup-batch/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.dat

doc/speedup-batch/Makefile

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
schnorrsig_data = schnorrsig_batch.dat schnorrsig_single.dat
2+
tweak_data = tweak_batch.dat tweak_single.dat
3+
4+
bench_output.txt: bench.sh
5+
SECP256K1_BENCH_ITERS=500000 ./bench.sh bench_output.txt
6+
7+
schnorrsig_batch.dat: bench_output.txt
8+
cat bench_output.txt | grep -v "schnorrsig_batch_verify_1 " | awk '{ gsub(/ /,""); print }' | awk -F, 'match($$0, /schnorrsig_batch_verify_([0-9]+)/, arr) {print arr[1] " " $$3}' > schnorrsig_batch.dat
9+
10+
schnorrsig_single.dat: bench_output.txt
11+
cat bench_output.txt | awk '{ gsub(/ /,""); print }' | awk -F, 'match($$0, /schnorrsig_verify/) {print $$3}' > schnorrsig_single.dat
12+
13+
tweak_batch.dat: bench_output.txt
14+
cat bench_output.txt | grep -v "tweak_check_batch_verify_1 " | awk '{ gsub(/ /,""); print }' | awk -F, 'match($$0, /tweak_check_batch_verify_([0-9]+)/, arr) {print arr[1] " " $$3}' > tweak_batch.dat
15+
16+
tweak_single.dat: bench_output.txt
17+
cat bench_output.txt | awk '{ gsub(/ /,""); print }' | awk -F, 'match($$0, /tweak_add_check/) {print $$3}' > tweak_single.dat
18+
19+
speedup-batch.png: $(schnorrsig_data) $(tweak_data) plot.gp
20+
gnuplot plot.gp
21+
22+
clean:
23+
rm *.log *.txt *.dat *.png

doc/speedup-batch/bench.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
output_file=$1
4+
cur_dir=$(pwd)
5+
6+
cd ../../
7+
echo "HEAD: $(git rev-parse --short HEAD)" > "$cur_dir/$output_file.log"
8+
make clean
9+
./autogen.sh
10+
./configure --enable-experimental --enable-module-batch --enable-module-schnorrsig >> "$cur_dir/$output_file.log"
11+
make -j
12+
./bench schnorrsig > "$cur_dir/$output_file"
13+
./bench extrakeys >> "$cur_dir/$output_file"

doc/speedup-batch/bench_output.txt

+137
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
Benchmark , Min(us) , Avg(us) , Max(us)
2+
3+
schnorrsig_sign , 50.4 , 50.5 , 50.7
4+
schnorrsig_verify , 89.1 , 89.2 , 89.3
5+
schnorrsig_batch_verify_1 , 104.0 , 104.0 , 104.0
6+
schnorrsig_batch_verify_2 , 89.0 , 89.1 , 89.1
7+
schnorrsig_batch_verify_3 , 84.1 , 84.1 , 84.1
8+
schnorrsig_batch_verify_4 , 81.5 , 81.5 , 81.5
9+
schnorrsig_batch_verify_5 , 79.9 , 79.9 , 79.9
10+
schnorrsig_batch_verify_7 , 78.0 , 78.1 , 78.3
11+
schnorrsig_batch_verify_9 , 77.0 , 77.0 , 77.1
12+
schnorrsig_batch_verify_11 , 76.2 , 76.3 , 76.3
13+
schnorrsig_batch_verify_14 , 75.6 , 75.6 , 75.6
14+
schnorrsig_batch_verify_17 , 75.2 , 75.2 , 75.2
15+
schnorrsig_batch_verify_21 , 74.8 , 74.8 , 74.8
16+
schnorrsig_batch_verify_26 , 74.5 , 74.6 , 74.9
17+
schnorrsig_batch_verify_32 , 74.3 , 74.5 , 74.7
18+
schnorrsig_batch_verify_39 , 74.1 , 74.1 , 74.1
19+
schnorrsig_batch_verify_47 , 73.9 , 73.9 , 73.9
20+
schnorrsig_batch_verify_57 , 74.5 , 74.5 , 74.5
21+
schnorrsig_batch_verify_69 , 74.3 , 74.3 , 74.5
22+
schnorrsig_batch_verify_83 , 74.1 , 74.1 , 74.2
23+
schnorrsig_batch_verify_100 , 73.9 , 74.0 , 74.1
24+
schnorrsig_batch_verify_121 , 74.1 , 74.1 , 74.2
25+
schnorrsig_batch_verify_146 , 73.9 , 73.9 , 74.0
26+
schnorrsig_batch_verify_176 , 74.0 , 74.2 , 74.5
27+
schnorrsig_batch_verify_212 , 73.9 , 74.1 , 74.1
28+
schnorrsig_batch_verify_255 , 74.0 , 74.0 , 74.1
29+
schnorrsig_batch_verify_307 , 73.9 , 74.0 , 74.1
30+
schnorrsig_batch_verify_369 , 73.9 , 73.9 , 73.9
31+
schnorrsig_batch_verify_443 , 73.9 , 74.1 , 74.3
32+
schnorrsig_batch_verify_532 , 74.0 , 74.0 , 74.1
33+
schnorrsig_batch_verify_639 , 73.9 , 74.0 , 74.0
34+
schnorrsig_batch_verify_767 , 73.9 , 73.9 , 73.9
35+
schnorrsig_batch_verify_921 , 74.0 , 74.0 , 74.1
36+
schnorrsig_batch_verify_1106 , 73.9 , 73.9 , 73.9
37+
schnorrsig_batch_verify_1328 , 73.9 , 74.1 , 74.2
38+
schnorrsig_batch_verify_1594 , 74.0 , 74.1 , 74.1
39+
schnorrsig_batch_verify_1913 , 74.0 , 74.0 , 74.0
40+
schnorrsig_batch_verify_2296 , 74.0 , 74.0 , 74.0
41+
schnorrsig_batch_verify_2756 , 73.9 , 74.0 , 74.1
42+
schnorrsig_batch_verify_3308 , 74.1 , 74.1 , 74.2
43+
schnorrsig_batch_verify_3970 , 74.1 , 74.2 , 74.4
44+
schnorrsig_batch_verify_4765 , 74.0 , 74.1 , 74.2
45+
schnorrsig_batch_verify_5719 , 74.0 , 74.1 , 74.1
46+
schnorrsig_batch_verify_6863 , 74.0 , 74.1 , 74.1
47+
schnorrsig_batch_verify_8236 , 74.0 , 74.1 , 74.1
48+
schnorrsig_batch_verify_9884 , 74.0 , 74.1 , 74.3
49+
schnorrsig_batch_verify_11861 , 74.0 , 74.0 , 74.1
50+
schnorrsig_batch_verify_14234 , 73.9 , 74.0 , 74.1
51+
schnorrsig_batch_verify_17081 , 73.9 , 73.9 , 73.9
52+
schnorrsig_batch_verify_20498 , 73.9 , 74.0 , 74.0
53+
schnorrsig_batch_verify_24598 , 73.9 , 74.0 , 74.1
54+
schnorrsig_batch_verify_29518 , 73.9 , 74.0 , 74.1
55+
schnorrsig_batch_verify_35422 , 73.9 , 73.9 , 73.9
56+
schnorrsig_batch_verify_42507 , 73.9 , 74.0 , 74.0
57+
schnorrsig_batch_verify_51009 , 73.9 , 74.1 , 74.3
58+
schnorrsig_batch_verify_61211 , 73.9 , 73.9 , 74.0
59+
schnorrsig_batch_verify_73454 , 73.9 , 74.0 , 74.3
60+
schnorrsig_batch_verify_88145 , 73.9 , 74.0 , 74.1
61+
schnorrsig_batch_verify_105775 , 74.0 , 74.1 , 74.1
62+
schnorrsig_batch_verify_126931 , 73.9 , 74.0 , 74.1
63+
schnorrsig_batch_verify_152318 , 73.9 , 73.9 , 74.0
64+
schnorrsig_batch_verify_182782 , 73.9 , 73.9 , 74.0
65+
schnorrsig_batch_verify_219339 , 73.9 , 73.9 , 74.0
66+
schnorrsig_batch_verify_263207 , 74.0 , 74.1 , 74.3
67+
schnorrsig_batch_verify_315849 , 73.9 , 74.0 , 74.0
68+
schnorrsig_batch_verify_379019 , 73.9 , 73.9 , 73.9
69+
schnorrsig_batch_verify_454823 , 74.0 , 74.0 , 74.0
70+
Benchmark , Min(us) , Avg(us) , Max(us)
71+
72+
tweak_add_check , 64.7 , 64.7 , 65.0
73+
tweak_check_batch_verify_1 , 69.7 , 69.8 , 69.8
74+
tweak_check_batch_verify_2 , 57.2 , 57.2 , 57.3
75+
tweak_check_batch_verify_3 , 52.0 , 52.1 , 52.2
76+
tweak_check_batch_verify_4 , 49.4 , 49.5 , 49.5
77+
tweak_check_batch_verify_5 , 47.9 , 47.9 , 47.9
78+
tweak_check_batch_verify_7 , 46.1 , 46.1 , 46.2
79+
tweak_check_batch_verify_9 , 45.2 , 45.2 , 45.4
80+
tweak_check_batch_verify_11 , 44.5 , 44.6 , 44.6
81+
tweak_check_batch_verify_14 , 43.9 , 43.9 , 43.9
82+
tweak_check_batch_verify_17 , 43.5 , 43.5 , 43.5
83+
tweak_check_batch_verify_21 , 43.1 , 43.1 , 43.1
84+
tweak_check_batch_verify_26 , 42.8 , 42.8 , 42.8
85+
tweak_check_batch_verify_32 , 42.5 , 42.6 , 42.6
86+
tweak_check_batch_verify_39 , 42.3 , 42.4 , 42.4
87+
tweak_check_batch_verify_47 , 42.2 , 42.2 , 42.2
88+
tweak_check_batch_verify_57 , 42.1 , 42.2 , 42.3
89+
tweak_check_batch_verify_69 , 42.0 , 42.1 , 42.1
90+
tweak_check_batch_verify_83 , 41.9 , 41.9 , 41.9
91+
tweak_check_batch_verify_100 , 41.8 , 41.9 , 41.9
92+
tweak_check_batch_verify_121 , 42.1 , 42.1 , 42.1
93+
tweak_check_batch_verify_146 , 42.0 , 42.0 , 42.0
94+
tweak_check_batch_verify_176 , 41.9 , 41.9 , 42.0
95+
tweak_check_batch_verify_212 , 41.8 , 41.9 , 41.9
96+
tweak_check_batch_verify_255 , 41.9 , 41.9 , 41.9
97+
tweak_check_batch_verify_307 , 41.8 , 41.9 , 41.9
98+
tweak_check_batch_verify_369 , 41.9 , 42.0 , 42.1
99+
tweak_check_batch_verify_443 , 41.9 , 41.9 , 41.9
100+
tweak_check_batch_verify_532 , 41.9 , 41.9 , 41.9
101+
tweak_check_batch_verify_639 , 41.9 , 41.9 , 42.0
102+
tweak_check_batch_verify_767 , 41.9 , 41.9 , 41.9
103+
tweak_check_batch_verify_921 , 41.9 , 41.9 , 41.9
104+
tweak_check_batch_verify_1106 , 41.9 , 41.9 , 41.9
105+
tweak_check_batch_verify_1328 , 41.9 , 41.9 , 42.0
106+
tweak_check_batch_verify_1594 , 41.9 , 41.9 , 42.0
107+
tweak_check_batch_verify_1913 , 41.9 , 41.9 , 41.9
108+
tweak_check_batch_verify_2296 , 41.9 , 41.9 , 41.9
109+
tweak_check_batch_verify_2756 , 41.8 , 41.9 , 41.9
110+
tweak_check_batch_verify_3308 , 41.9 , 41.9 , 42.0
111+
tweak_check_batch_verify_3970 , 41.9 , 41.9 , 41.9
112+
tweak_check_batch_verify_4765 , 41.8 , 41.9 , 41.9
113+
tweak_check_batch_verify_5719 , 41.9 , 42.0 , 42.1
114+
tweak_check_batch_verify_6863 , 42.0 , 42.0 , 42.0
115+
tweak_check_batch_verify_8236 , 42.0 , 42.0 , 42.0
116+
tweak_check_batch_verify_9884 , 41.9 , 41.9 , 42.0
117+
tweak_check_batch_verify_11861 , 41.9 , 42.0 , 42.1
118+
tweak_check_batch_verify_14234 , 41.9 , 42.0 , 42.0
119+
tweak_check_batch_verify_17081 , 41.8 , 41.9 , 41.9
120+
tweak_check_batch_verify_20498 , 41.8 , 41.9 , 41.9
121+
tweak_check_batch_verify_24598 , 41.8 , 41.9 , 41.9
122+
tweak_check_batch_verify_29518 , 41.9 , 41.9 , 41.9
123+
tweak_check_batch_verify_35422 , 41.9 , 41.9 , 41.9
124+
tweak_check_batch_verify_42507 , 41.8 , 41.8 , 41.9
125+
tweak_check_batch_verify_51009 , 41.9 , 41.9 , 41.9
126+
tweak_check_batch_verify_61211 , 41.8 , 41.8 , 41.8
127+
tweak_check_batch_verify_73454 , 41.8 , 42.0 , 42.2
128+
tweak_check_batch_verify_88145 , 41.9 , 41.9 , 41.9
129+
tweak_check_batch_verify_105775 , 41.8 , 41.8 , 41.8
130+
tweak_check_batch_verify_126931 , 41.8 , 41.9 , 41.9
131+
tweak_check_batch_verify_152318 , 41.8 , 41.9 , 42.0
132+
tweak_check_batch_verify_182782 , 41.9 , 41.9 , 41.9
133+
tweak_check_batch_verify_219339 , 41.9 , 42.0 , 42.0
134+
tweak_check_batch_verify_263207 , 41.9 , 42.0 , 42.1
135+
tweak_check_batch_verify_315849 , 41.9 , 41.9 , 41.9
136+
tweak_check_batch_verify_379019 , 41.9 , 41.9 , 42.0
137+
tweak_check_batch_verify_454823 , 41.9 , 41.9 , 41.9
+127
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
HEAD: 6ddb0d0c
2+
checking build system type... x86_64-pc-linux-gnu
3+
checking host system type... x86_64-pc-linux-gnu
4+
checking for a BSD-compatible install... /usr/bin/install -c
5+
checking whether build environment is sane... yes
6+
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
7+
checking for gawk... gawk
8+
checking whether make sets $(MAKE)... yes
9+
checking whether make supports nested variables... yes
10+
checking whether make supports nested variables... (cached) yes
11+
checking for gcc... gcc
12+
checking whether the C compiler works... yes
13+
checking for C compiler default output file name... a.out
14+
checking for suffix of executables...
15+
checking whether we are cross compiling... no
16+
checking for suffix of object files... o
17+
checking whether we are using the GNU C compiler... yes
18+
checking whether gcc accepts -g... yes
19+
checking for gcc option to accept ISO C89... none needed
20+
checking whether gcc understands -c and -o together... yes
21+
checking whether make supports the include directive... yes (GNU style)
22+
checking dependency style of gcc... gcc3
23+
checking dependency style of gcc... gcc3
24+
checking for ar... ar
25+
checking the archiver (ar) interface... ar
26+
checking how to print strings... printf
27+
checking for a sed that does not truncate output... /usr/bin/sed
28+
checking for grep that handles long lines and -e... /usr/bin/grep
29+
checking for egrep... /usr/bin/grep -E
30+
checking for fgrep... /usr/bin/grep -F
31+
checking for ld used by gcc... /usr/bin/ld
32+
checking if the linker (/usr/bin/ld) is GNU ld... yes
33+
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
34+
checking the name lister (/usr/bin/nm -B) interface... BSD nm
35+
checking whether ln -s works... yes
36+
checking the maximum length of command line arguments... 1572864
37+
checking how to convert x86_64-pc-linux-gnu file names to x86_64-pc-linux-gnu format... func_convert_file_noop
38+
checking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noop
39+
checking for /usr/bin/ld option to reload object files... -r
40+
checking for objdump... objdump
41+
checking how to recognize dependent libraries... pass_all
42+
checking for dlltool... no
43+
checking how to associate runtime and link libraries... printf %s\n
44+
checking for archiver @FILE support... @
45+
checking for strip... strip
46+
checking for ranlib... ranlib
47+
checking command to parse /usr/bin/nm -B output from gcc object... ok
48+
checking for sysroot... no
49+
checking for a working dd... /usr/bin/dd
50+
checking how to truncate binary pipes... /usr/bin/dd bs=4096 count=1
51+
checking for mt... mt
52+
checking if mt is a manifest tool... no
53+
checking how to run the C preprocessor... gcc -E
54+
checking for ANSI C header files... yes
55+
checking for sys/types.h... yes
56+
checking for sys/stat.h... yes
57+
checking for stdlib.h... yes
58+
checking for string.h... yes
59+
checking for memory.h... yes
60+
checking for strings.h... yes
61+
checking for inttypes.h... yes
62+
checking for stdint.h... yes
63+
checking for unistd.h... yes
64+
checking for dlfcn.h... yes
65+
checking for objdir... .libs
66+
checking if gcc supports -fno-rtti -fno-exceptions... no
67+
checking for gcc option to produce PIC... -fPIC -DPIC
68+
checking if gcc PIC flag -fPIC -DPIC works... yes
69+
checking if gcc static flag -static works... yes
70+
checking if gcc supports -c -o file.o... yes
71+
checking if gcc supports -c -o file.o... (cached) yes
72+
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
73+
checking whether -lc should be explicitly linked in... no
74+
checking dynamic linker characteristics... GNU/Linux ld.so
75+
checking how to hardcode library paths into programs... immediate
76+
checking whether stripping libraries is possible... yes
77+
checking if libtool supports shared libraries... yes
78+
checking whether to build shared libraries... yes
79+
checking whether to build static libraries... yes
80+
checking if gcc supports -Werror=unknown-warning-option... no
81+
checking if gcc supports -std=c89 -pedantic -Wno-long-long -Wnested-externs -Wshadow -Wstrict-prototypes -Wundef... yes
82+
checking if gcc supports -Wno-overlength-strings... yes
83+
checking if gcc supports -Wall... yes
84+
checking if gcc supports -Wno-unused-function... yes
85+
checking if gcc supports -Wextra... yes
86+
checking if gcc supports -Wcast-align... yes
87+
checking if gcc supports -Wcast-align=strict... yes
88+
checking if gcc supports -Wconditional-uninitialized... no
89+
checking if gcc supports -fvisibility=hidden... yes
90+
checking for valgrind support... yes
91+
checking for x86_64 assembly availability... yes
92+
configure: ******
93+
configure: WARNING: experimental build
94+
configure: Experimental features do not have stable APIs or properties, and may not be safe for production use.
95+
configure: Building batch verification module: yes
96+
configure: ******
97+
checking that generated files are newer than configure... done
98+
configure: creating ./config.status
99+
config.status: creating Makefile
100+
config.status: creating libsecp256k1.pc
101+
config.status: creating src/libsecp256k1-config.h
102+
config.status: src/libsecp256k1-config.h is unchanged
103+
config.status: executing depfiles commands
104+
config.status: executing libtool commands
105+
106+
Build Options:
107+
with external callbacks = no
108+
with benchmarks = yes
109+
with tests = yes
110+
with coverage = no
111+
with examples = no
112+
module ecdh = no
113+
module recovery = no
114+
module extrakeys = yes
115+
module schnorrsig = yes
116+
module batch = yes
117+
118+
asm = x86_64
119+
ecmult window size = 15
120+
ecmult gen prec. bits = 4
121+
122+
valgrind = yes
123+
CC = gcc
124+
CPPFLAGS =
125+
SECP_CFLAGS = -O2 -std=c89 -pedantic -Wno-long-long -Wnested-externs -Wshadow -Wstrict-prototypes -Wundef -Wno-overlength-strings -Wall -Wno-unused-function -Wextra -Wcast-align -Wcast-align=strict -fvisibility=hidden
126+
CFLAGS = -g -O2
127+
LDFLAGS =

0 commit comments

Comments
 (0)