Skip to content

Commit 44083bc

Browse files
committed
perf: optimize Az awareness helpers
Signed-off-by: Rueian <[email protected]>
1 parent ddb7619 commit 44083bc

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

helper.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -412,11 +412,6 @@ func AZAffinityNodeSelector(clientAZ string) ReadNodeSelectorFunc {
412412
return newAZSelector(clientAZ, 1)
413413
}
414414

415-
// AZAffinityReplicaSelector prioritizes replicas in the same AZ using Round-Robin.
416-
func AZAffinityReplicaSelector(clientAZ string) ReplicaSelectorFunc {
417-
return newAZSelector(clientAZ, 0)
418-
}
419-
420415
// AZAffinityReplicasAndPrimaryNodeSelector prioritizes:
421416
// 1. Same-AZ Replicas
422417
// 2. Same-AZ Primary
@@ -474,12 +469,12 @@ func pickAZ(nodes []NodeInfo, clientAZ string, startIdx int, counter *atomic.Uin
474469

475470
// We cap the search at 255 nodes
476471
limit := min(n, 255)
477-
var matches [8]int
472+
var matches [8]uint8
478473
var count uint32 = 0
479474

480475
for i := startIdx; i < limit; i++ {
481476
if nodes[i].AZ == clientAZ {
482-
matches[count] = i
477+
matches[count] = uint8(i)
483478
count++
484479
if count == 8 {
485480
break
@@ -495,5 +490,5 @@ func pickAZ(nodes []NodeInfo, clientAZ string, startIdx int, counter *atomic.Uin
495490
c := counter.Add(1)
496491
k := c % count
497492

498-
return matches[k]
493+
return int(matches[k])
499494
}

0 commit comments

Comments
 (0)