Skip to content

Commit 12e5ed2

Browse files
wenyihu6tbg
authored andcommitted
asim: fix snapshot rate delay integer division
Previously, integer division was used when computing the delay for adding a replica, resulting in shorter than expected delays. This patch improves accuracy in tracking the delay by calculating a ratio with float. This also aligns with how pkg/cmd/roachtest/tests/decommissionbench.go estimates decommission duration. (Note: This issue was just raised in Slack, not from the prototype.) Epic: none Release note: none
1 parent 243aa8f commit 12e5ed2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pkg/kv/kvserver/asim/config/settings.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ func (s *SimulationSettings) ReplicaChangeDelayFn() func(rangeSize int64, add bo
162162
return func(rangeSize int64, add bool) time.Duration {
163163
delay := s.ReplicaChangeBaseDelay
164164
if add {
165-
delay += (time.Duration(rangeSize) / time.Duration(s.RebalancingSnapshotRate)) * time.Second
165+
estimatedTimeToAddReplica := float64(rangeSize) / float64(s.RebalancingSnapshotRate)
166+
delay += time.Duration(estimatedTimeToAddReplica) * time.Second
166167
}
167168
return delay
168169
}

0 commit comments

Comments
 (0)