Skip to content

Commit

Permalink
use cache
Browse files Browse the repository at this point in the history
Signed-off-by: bufferflies <1045931706@qq.com>
  • Loading branch information
bufferflies committed Apr 12, 2023
1 parent 6a7d122 commit 65c5f24
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions pkg/statistics/store_hot_peers_infos.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,19 +183,21 @@ func summaryStoresLoadByEngine(
ty = "query-rate-" + rwTy.String() + "-" + kind.String()
hotPeerSummary.WithLabelValues(ty, fmt.Sprintf("%v", id)).Set(peerLoadSum[QueryDim])
}
loads := collector.GetLoads(storeLoads, peerLoadSum, rwTy, kind)

historyLoads := storesHistoryLoads.Get(id, rwTy, kind)
for i, loads := range historyLoads {
if allStoreHistoryLoadSum[i] == nil || len(allStoreHistoryLoadSum[i]) < len(loads) {
allStoreHistoryLoadSum[i] = make([]float64, len(loads))
}
for j, load := range loads {
allStoreHistoryLoadSum[i][j] += load
if storesHistoryLoads != nil {
historyLoads := storesHistoryLoads.Get(id, rwTy, kind)
for i, loads := range historyLoads {
if allStoreHistoryLoadSum[i] == nil || len(allStoreHistoryLoadSum[i]) < len(loads) {
allStoreHistoryLoadSum[i] = make([]float64, len(loads))
}
for j, load := range loads {
allStoreHistoryLoadSum[i][j] += load
}
}
storesHistoryLoads.Add(id, rwTy, kind, loads)
}

loads := collector.GetLoads(storeLoads, peerLoadSum, rwTy, kind)
storesHistoryLoads.Add(id, rwTy, kind, loads)
for i := range allStoreLoadSum {
allStoreLoadSum[i] += loads[i]
}
Expand Down

0 comments on commit 65c5f24

Please sign in to comment.