performance regression between 5cedcb87 and be981046
All runs bellow use sqlite@132978c7 but different libc commits (hence the `GO111MODULE=off`).
Current tip (e473cf1f) brought some substantial perfomance improvements. However, it turns out the performace only catched back to where we were with 5cedcb87 because between 5cedcb87 and be981046 something introduced performance regressions that went unnoticed. That's my fault.
Tip e473cf1f (Sun Jan 17 11:19:22 2021 +0100):
```
jnml@3900x:~/src/modernc.org/sqlite$ GO111MODULE=off go test -tags cgobench -run @ -bench Comparative/sqlite[^3] -recs_per_sec_as_mbps |& tee log-insert-e473cf1f
test binary compiled for linux/amd64
goos: linux
goarch: amd64
pkg: modernc.org/sqlite
BenchmarkInsertComparative/sqliteInMemory1e1-24 25213 46282 ns/op 216066.95 MB/s 1360 B/op 64 allocs/op
BenchmarkInsertComparative/sqliteInMemory1e2-24 2888 423330 ns/op 236222.38 MB/s 12880 B/op 604 allocs/op
BenchmarkInsertComparative/sqliteInMemory1e3-24 286 4064304 ns/op 246044.58 MB/s 134032 B/op 6748 allocs/op
BenchmarkInsertComparative/sqliteInMemory1e4-24 27 40447288 ns/op 247235.36 MB/s 1358037 B/op 69748 allocs/op
BenchmarkInsertComparative/sqliteInMemory1e5-24 3 387164657 ns/op 258288.04 MB/s 13598128 B/op 699748 allocs/op
BenchmarkInsertComparative/sqliteInMemory1e6-24 1 4030636896 ns/op 248099.75 MB/s 135999880 B/op 6999757 allocs/op
BenchmarkInsertComparative/sqliteOnDisk1e1-24 864 1395818 ns/op 7164.26 MB/s 1440 B/op 76 allocs/op
BenchmarkInsertComparative/sqliteOnDisk1e2-24 606 1909028 ns/op 52382.68 MB/s 12960 B/op 616 allocs/op
BenchmarkInsertComparative/sqliteOnDisk1e3-24 220 5497861 ns/op 181888.91 MB/s 134113 B/op 6760 allocs/op
BenchmarkInsertComparative/sqliteOnDisk1e4-24 26 41729898 ns/op 239636.34 MB/s 1358120 B/op 69760 allocs/op
BenchmarkInsertComparative/sqliteOnDisk1e5-24 3 397684339 ns/op 251455.72 MB/s 13598154 B/op 699760 allocs/op
BenchmarkInsertComparative/sqliteOnDisk1e6-24 1 4030089912 ns/op 248133.42 MB/s 135998800 B/op 6999760 allocs/op
PASS
ok modernc.org/sqlite 25.126s
jnml@3900x:~/src/modernc.org/sqlite$
```
5cedcb87 (Sat Jan 16 10:50:58 2021 -0500):
```
jnml@3900x:~/src/modernc.org/sqlite$ GO111MODULE=off go test -tags cgobench -run @ -bench Comparative/sqlite[^3] -recs_per_sec_as_mbps |& tee log-insert-5cedcb87
test binary compiled for linux/amd64
goos: linux
goarch: amd64
pkg: modernc.org/sqlite
BenchmarkInsertComparative/sqliteInMemory1e1-24 25518 48248 ns/op 207261.73 MB/s 1360 B/op 64 allocs/op
BenchmarkInsertComparative/sqliteInMemory1e2-24 2743 416718 ns/op 239970.45 MB/s 12880 B/op 604 allocs/op
BenchmarkInsertComparative/sqliteInMemory1e3-24 291 4064130 ns/op 246055.11 MB/s 134032 B/op 6748 allocs/op
BenchmarkInsertComparative/sqliteInMemory1e4-24 31 39999999 ns/op 250000.01 MB/s 1358037 B/op 69748 allocs/op
BenchmarkInsertComparative/sqliteInMemory1e5-24 3 404024461 ns/op 247509.77 MB/s 13598106 B/op 699748 allocs/op
BenchmarkInsertComparative/sqliteInMemory1e6-24 1 4040651808 ns/op 247484.82 MB/s 135999912 B/op 6999757 allocs/op
BenchmarkInsertComparative/sqliteOnDisk1e1-24 840 1367487 ns/op 7312.68 MB/s 1440 B/op 76 allocs/op
BenchmarkInsertComparative/sqliteOnDisk1e2-24 634 1960564 ns/op 51005.74 MB/s 12960 B/op 616 allocs/op
BenchmarkInsertComparative/sqliteOnDisk1e3-24 223 5486140 ns/op 182277.51 MB/s 134113 B/op 6760 allocs/op
BenchmarkInsertComparative/sqliteOnDisk1e4-24 27 42212995 ns/op 236893.88 MB/s 1358119 B/op 69760 allocs/op
BenchmarkInsertComparative/sqliteOnDisk1e5-24 3 405054650 ns/op 246880.27 MB/s 13598234 B/op 699760 allocs/op
BenchmarkInsertComparative/sqliteOnDisk1e6-24 1 4077270452 ns/op 245262.12 MB/s 135999104 B/op 6999764 allocs/op
PASS
ok modernc.org/sqlite 25.572s
jnml@3900x:~/src/modernc.org/sqlite$
```
be981046 (Sat Jan 16 21:03:39 2021 +0000):
```
jnml@3900x:~/src/modernc.org/sqlite$ GO111MODULE=off go test -tags cgobench -run @ -bench Comparative/sqlite[^3] -recs_per_sec_as_mbps |& tee log-insert-be981046
test binary compiled for linux/amd64
goos: linux
goarch: amd64
pkg: modernc.org/sqlite
BenchmarkInsertComparative/sqliteInMemory1e1-24 25088 85139 ns/op 117455.62 MB/s 1360 B/op 64 allocs/op
BenchmarkInsertComparative/sqliteInMemory1e2-24 2778 781842 ns/op 127903.11 MB/s 12880 B/op 604 allocs/op
BenchmarkInsertComparative/sqliteInMemory1e3-24 268 7988312 ns/op 125182.90 MB/s 134032 B/op 6748 allocs/op
BenchmarkInsertComparative/sqliteInMemory1e4-24 26 79472593 ns/op 125829.54 MB/s 1358043 B/op 69748 allocs/op
BenchmarkInsertComparative/sqliteInMemory1e5-24 2 748891012 ns/op 133530.78 MB/s 13598132 B/op 699749 allocs/op
BenchmarkInsertComparative/sqliteInMemory1e6-24 1 9747098791 ns/op 102594.63 MB/s 136004928 B/op 6999758 allocs/op
BenchmarkInsertComparative/sqliteOnDisk1e1-24 871 1340394 ns/op 7460.49 MB/s 1440 B/op 76 allocs/op
BenchmarkInsertComparative/sqliteOnDisk1e2-24 634 1868381 ns/op 53522.27 MB/s 12960 B/op 616 allocs/op
BenchmarkInsertComparative/sqliteOnDisk1e3-24 216 8563377 ns/op 116776.36 MB/s 134113 B/op 6760 allocs/op
BenchmarkInsertComparative/sqliteOnDisk1e4-24 26 78824430 ns/op 126864.22 MB/s 1358122 B/op 69760 allocs/op
BenchmarkInsertComparative/sqliteOnDisk1e5-24 2 716794700 ns/op 139509.96 MB/s 13598208 B/op 699760 allocs/op
BenchmarkInsertComparative/sqliteOnDisk1e6-24 1 9656741911 ns/op 103554.60 MB/s 135999248 B/op 6999764 allocs/op
PASS
ok modernc.org/sqlite 41.230s
jnml@3900x:~/src/modernc.org/sqlite$
```
Comparing:
```
jnml@3900x:~/src/modernc.org/sqlite$ benchcmp -changed log-insert-5cedcb87 log-insert-be981046
benchcmp is deprecated in favor of benchstat: https://pkg.go.dev/golang.org/x/perf/cmd/benchstat
benchmark old ns/op new ns/op delta
BenchmarkInsertComparative/sqliteInMemory1e1-24 48248 85139 +76.46%
BenchmarkInsertComparative/sqliteInMemory1e2-24 416718 781842 +87.62%
BenchmarkInsertComparative/sqliteInMemory1e3-24 4064130 7988312 +96.56%
BenchmarkInsertComparative/sqliteInMemory1e4-24 39999999 79472593 +98.68%
BenchmarkInsertComparative/sqliteInMemory1e5-24 404024461 748891012 +85.36%
BenchmarkInsertComparative/sqliteInMemory1e6-24 4040651808 9747098791 +141.23%
BenchmarkInsertComparative/sqliteOnDisk1e1-24 1367487 1340394 -1.98%
BenchmarkInsertComparative/sqliteOnDisk1e2-24 1960564 1868381 -4.70%
BenchmarkInsertComparative/sqliteOnDisk1e3-24 5486140 8563377 +56.09%
BenchmarkInsertComparative/sqliteOnDisk1e4-24 42212995 78824430 +86.73%
BenchmarkInsertComparative/sqliteOnDisk1e5-24 405054650 716794700 +76.96%
BenchmarkInsertComparative/sqliteOnDisk1e6-24 4077270452 9656741911 +136.84%
benchmark old MB/s new MB/s speedup
BenchmarkInsertComparative/sqliteInMemory1e1-24 207261.73 117455.62 0.57x
BenchmarkInsertComparative/sqliteInMemory1e2-24 239970.45 127903.11 0.53x
BenchmarkInsertComparative/sqliteInMemory1e3-24 246055.11 125182.90 0.51x
BenchmarkInsertComparative/sqliteInMemory1e4-24 250000.01 125829.54 0.50x
BenchmarkInsertComparative/sqliteInMemory1e5-24 247509.77 133530.78 0.54x
BenchmarkInsertComparative/sqliteInMemory1e6-24 247484.82 102594.63 0.41x
BenchmarkInsertComparative/sqliteOnDisk1e1-24 7312.68 7460.49 1.02x
BenchmarkInsertComparative/sqliteOnDisk1e2-24 51005.74 53522.27 1.05x
BenchmarkInsertComparative/sqliteOnDisk1e3-24 182277.51 116776.36 0.64x
BenchmarkInsertComparative/sqliteOnDisk1e4-24 236893.88 126864.22 0.54x
BenchmarkInsertComparative/sqliteOnDisk1e5-24 246880.27 139509.96 0.57x
BenchmarkInsertComparative/sqliteOnDisk1e6-24 245262.12 103554.60 0.42x
benchmark old allocs new allocs delta
BenchmarkInsertComparative/sqliteInMemory1e5-24 699748 699749 +0.00%
BenchmarkInsertComparative/sqliteInMemory1e6-24 6999757 6999758 +0.00%
benchmark old bytes new bytes delta
BenchmarkInsertComparative/sqliteInMemory1e4-24 1358037 1358043 +0.00%
BenchmarkInsertComparative/sqliteInMemory1e5-24 13598106 13598132 +0.00%
BenchmarkInsertComparative/sqliteInMemory1e6-24 135999912 136004928 +0.00%
BenchmarkInsertComparative/sqliteOnDisk1e4-24 1358119 1358122 +0.00%
BenchmarkInsertComparative/sqliteOnDisk1e5-24 13598234 13598208 -0.00%
BenchmarkInsertComparative/sqliteOnDisk1e6-24 135999104 135999248 +0.00%
jnml@3900x:~/src/modernc.org/sqlite$
```
We need to investigate why this happened and if we can get back the lost performance.
@amfiremage Please take a look if you can find something, thank you.
issue