@@ -13,8 +13,9 @@ import (
13
13
)
14
14
15
15
// MMARebalanceAdvisor contains information that mma needs to determine if a
16
- // candidate is in conflict with its goals. All fields should be immutable after
17
- // its initialization.
16
+ // candidate is in conflict with its goals. The caller should not access/change
17
+ // its internal fields after creation and should use IsInConflictWithMMA
18
+ // instead.
18
19
//
19
20
// MMARebalanceAdvisor uses the meansLoad summary to compute the load summary
20
21
// for a provided candidate. Then it compares the candidate load summary against
@@ -47,11 +48,32 @@ func NoopMMARebalanceAdvisor() *MMARebalanceAdvisor {
47
48
48
49
// BuildMMARebalanceAdvisor constructs an MMARebalanceAdvisor for the given
49
50
// existing store and candidate stores. The advisor can be used to determine if
50
- // a candidate is in conflict with the existing store via IsInConflictWithMMA.
51
- // The provided cands list may or may not include the existing store. This
52
- // method always adds the existing store to the cands list so that it is
53
- // included in the mean calculation. It is up to computeMeansForStoreSet to
54
- // handle the de-duplication of storeIDs from the cands list.
51
+ // a candidate is vetoed by the multi-metric allocator due to running counter to
52
+ // its goals. Currently, it is considered counter to its goal if the candidate
53
+ // is more overloaded than the existing store with respect to the cands list.
54
+ //
55
+ // The provided cands list may or may not include the existing store. For the
56
+ // replicate queue, the cands list is just the set of candidate stores for the
57
+ // equivalence class, excluding the existing store. For the lease queue, the
58
+ // cands list includes all stores that satisfy the constraint including the
59
+ // existing store.
60
+ //
61
+ // This method always adds the existing store to the cands list to ensure it is
62
+ // included in the mean calculation. This is subject to change, but currently it
63
+ // does not make sense to compute the load summary of the existing store with
64
+ // respect to the cands list that does not include the existing store itself.
65
+ // Alternatively, we could require the cands list to be exactly the same as the
66
+ // set of stores used to compute the means for lease / range count. The existing
67
+ // store should be included for the lease queue but excluded for the replicate
68
+ // queue. Note that since this method always adds the existing store to the
69
+ // list, and the provided cands may or may not already include the existing
70
+ // store, the cands slice passed to computeMeansForStoreSet may contain
71
+ // duplicate storeIDs. It is up to computeMeansForStoreSet to handle
72
+ // de-duplication of storeIDs from the cands list.
73
+ //
74
+ // The returned advisor should be passed to IsInConflictWithMMA as a helper to
75
+ // determine if a candidate is vetoed by the multi-metric allocator due to
76
+ // running counter to its goals.
55
77
func (a * allocatorState ) BuildMMARebalanceAdvisor (
56
78
existing roachpb.StoreID , cands []roachpb.StoreID ,
57
79
) * MMARebalanceAdvisor {
@@ -70,8 +92,12 @@ func (a *allocatorState) BuildMMARebalanceAdvisor(
70
92
// IsInConflictWithMMA determines if the given candidate is in conflict with the
71
93
// existing store using the provided MMARebalanceAdvisor. For simplicity, we
72
94
// currently say that this is in conflict if the candidate is more overloaded
73
- // than the existing store. This is subject to change in the future. Caller is
74
- // responsible for making sure the MMARebalanceAdvisor is for the correct
95
+ // than the existing store. This is subject to change in the future. When
96
+ // cpuOnly is true, the candidate store's cpu load summary must not exceed that
97
+ // of the existing store, or the operation is considered in conflict. When
98
+ // cpuOnly is false, the worst dimension's summary is compared instead.
99
+ //
100
+ // Caller is responsible for making sure the MMARebalanceAdvisor is for the correct
75
101
// existing store and candidate set.
76
102
func (a * allocatorState ) IsInConflictWithMMA (
77
103
ctx context.Context , cand roachpb.StoreID , advisor * MMARebalanceAdvisor , cpuOnly bool ,
@@ -88,13 +114,14 @@ func (a *allocatorState) IsInConflictWithMMA(
88
114
// Always compute the candidate's load summary.
89
115
candSLS := a .cs .computeLoadSummary (ctx , cand , & advisor .means .storeLoad , & advisor .means .nodeLoad )
90
116
117
+ // TODO(wenyihu6): unify the branches below by assigning based on sls.worstDim and cpuOnly.
91
118
var conflict bool
92
119
if cpuOnly {
93
120
conflict = candSLS .dimSummary [CPURate ] > existingSLS .dimSummary [CPURate ]
94
121
if conflict {
95
122
log .KvDistribution .VEventf (
96
123
ctx , 2 ,
97
- "mma rejected candidate s%d(cpu-only) as a replacement for s%d: candidate=%v > existing=%v" ,
124
+ "mma rejected candidate s%d(cpu-only) as a replacement for s%d: candidate=%v(cpu) > existing=%v(cpu) " ,
98
125
cand , advisor .existingStoreID , candSLS .dimSummary [CPURate ], existingSLS .dimSummary [CPURate ],
99
126
)
100
127
}
@@ -103,8 +130,8 @@ func (a *allocatorState) IsInConflictWithMMA(
103
130
if conflict {
104
131
log .KvDistribution .VEventf (
105
132
ctx , 2 ,
106
- "mma rejected candidate s%d as a replacement for s%d: candidate=%v > existing=%v" ,
107
- cand , advisor .existingStoreID , candSLS .sls , existingSLS .sls ,
133
+ "mma rejected candidate s%d as a replacement for s%d: candidate=%v(%v) > existing=%v(%v) " ,
134
+ cand , advisor .existingStoreID , candSLS .sls , candSLS . worstDim , existingSLS .sls , existingSLS . worstDim ,
108
135
)
109
136
}
110
137
}
0 commit comments