Skip to content

Commit 5a66af4

Browse files
committed
kvserver: let BenchmarkEmptyRebalance wait for the raft group to be ready
For leader leases, the raft group will take a few seconds before it can propose new entries because it needs store liveness heartbeats to start. This commit modifies the benchmark by making it wait until the group is ready. Benchmark results: name old time/op new time/op delta EmptyRebalance/add-remove-12 2.85s ± 1% 0.03s ± 8% -98.96% (p=0.000 n=7+8) name old alloc/op new alloc/op delta EmptyRebalance/add-remove-12 12.3MB ±13% 1.9MB ± 3% -84.85% (p=0.000 n=10+8) name old allocs/op new allocs/op delta EmptyRebalance/add-remove-12 64.7k ± 2% 10.8k ± 0% -83.29% (p=0.000 n=10+8) Fixes: #144940 Release note: None
1 parent acfdcc8 commit 5a66af4

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pkg/kv/kvserver/client_replica_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5795,6 +5795,17 @@ func BenchmarkEmptyRebalance(b *testing.B) {
57955795
defer tc.Stopper().Stop(ctx)
57965796

57975797
scratchRange := tc.ScratchRange(b)
5798+
5799+
// Before actually starting the benchmark, we need to make sure that the raft
5800+
// group is able to add/remove voters. This is important because in leader
5801+
// leases, it takes a few seconds for store liveness heartbeats to start.
5802+
// We need store liveness heartbeats for two reasons: (1) By default,
5803+
// followers won't campaign unless they are supported by a quorum of peers,
5804+
// and (2) The leader won't be able to propose config changes unless the new
5805+
// config doesn't cause a regression in the LeadSupportUntil.
5806+
tc.AddVotersOrFatal(b, scratchRange, tc.Target(1))
5807+
tc.RemoveVotersOrFatal(b, scratchRange, tc.Target(1))
5808+
57985809
b.Run("add-remove", func(b *testing.B) {
57995810
b.ResetTimer()
58005811
for i := 0; i < b.N; i++ {

0 commit comments

Comments
 (0)