Skip to content

Add benchmarks for Updater

Sami Hiltunen requested to merge smh-update-ref-benchmark into master

Our update-ref wrapper doesn't have currently any benchmarks. This MR adds benchmarks for both updates and deletions. Deletions are also benchmarked with refs loose and packed. Creations are not benchmarked separately as the operation is the same as an update.

The performance of update-ref is important for &8903 and &8911 as all reference updates need to be serialized and applied through the log. The benchmarks here give us an idea of what sort of reference change throughput we can achieve with log application.

Running the benchmark on my laptop gives us few points:

  1. Reference update throughput caps at 50 updates/s. This means we currently can't achieve high enough throughput to match our peak load mutator rates. The results do not get better with increased transaction sizes.
  2. Reference deletion throughput with packed refs matches the update throughput when transaction size is 1. The performance improves dramatically when transaction size is increased.

Deletions respond well to bigger transaction sizes which gives us some leeway in optimizing our log processing by batching multiple transactions into a single write. This is likely due to packed-refs file having to be rewritten only once for a deletion. The reference updates end up in loose files regardless of the transaction size which makes batching transactions quite ineffective. This will likely get better with future reference file formats in Git as they'd allow for batching multiple transactions into a single write.

Benchmark Results
goos: darwin
goarch: amd64
pkg: gitlab.com/gitlab-org/gitaly/v15/internal/git/updateref
cpu: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
BenchmarkUpdater
BenchmarkUpdater/update
BenchmarkUpdater/update/transaction_size:_1
BenchmarkUpdater/update/transaction_size:_1-16         	      52	  20710401 ns/op	        48.32 reference_updates/s	     269 B/op	      12 allocs/op
BenchmarkUpdater/update/transaction_size:_10
BenchmarkUpdater/update/transaction_size:_10-16        	       6	 199396022 ns/op	        50.18 reference_updates/s	    2881 B/op	      57 allocs/op
BenchmarkUpdater/update/transaction_size:_100
BenchmarkUpdater/update/transaction_size:_100-16       	       1	2002251276 ns/op	        49.96 reference_updates/s	   18808 B/op	     450 allocs/op
BenchmarkUpdater/delete
BenchmarkUpdater/delete/reference_count_100/references_packed_false/transaction_size_1
BenchmarkUpdater/delete/reference_count_100/references_packed_false/transaction_size_1-16         	    1393	    941592 ns/op	      1063 reference_deletions/s	     206 B/op	      11 allocs/op
BenchmarkUpdater/delete/reference_count_100/references_packed_true/transaction_size_1
BenchmarkUpdater/delete/reference_count_100/references_packed_true/transaction_size_1-16          	      57	  21183865 ns/op	        47.23 reference_deletions/s	     278 B/op	      11 allocs/op
BenchmarkUpdater/delete/reference_count_100/references_packed_false/transaction_size_10
BenchmarkUpdater/delete/reference_count_100/references_packed_false/transaction_size_10-16        	     306	   4080364 ns/op	      2452 reference_deletions/s	     702 B/op	      38 allocs/op
BenchmarkUpdater/delete/reference_count_100/references_packed_true/transaction_size_10
BenchmarkUpdater/delete/reference_count_100/references_packed_true/transaction_size_10-16         	      44	  24515611 ns/op	       408.1 reference_deletions/s	     819 B/op	      39 allocs/op
BenchmarkUpdater/delete/reference_count_100/references_packed_false/transaction_size_100
BenchmarkUpdater/delete/reference_count_100/references_packed_false/transaction_size_100-16       	      48	  24458077 ns/op	      4090 reference_deletions/s	    5800 B/op	     308 allocs/op
BenchmarkUpdater/delete/reference_count_100/references_packed_true/transaction_size_100
BenchmarkUpdater/delete/reference_count_100/references_packed_true/transaction_size_100-16        	      31	  37074623 ns/op	      2699 reference_deletions/s	    5885 B/op	     309 allocs/op
PASS
ok  	gitlab.com/gitlab-org/gitaly/v15/internal/git/updateref	365.684s

Merge request reports