Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

statistics: kill in time when to run topnStatsMergeWorker and improve memory #45765

Merged
merged 2 commits into from
Aug 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions statistics/merge_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,7 @@
return
}
partNum := len(allTopNs)
checkNum := len(checkTopNs)
topNsNum := make([]int, checkNum)
removeVals := make([][]TopNMeta, partNum)
for i, topN := range checkTopNs {
if topN == nil {
topNsNum[i] = 0
continue
}
topNsNum[i] = len(topN.TopN)
}
// Different TopN structures may hold the same value, we have to merge them.
counter := make(map[hack.MutableString]float64)
// datumMap is used to store the mapping from the string type to datum type.
Expand Down Expand Up @@ -136,6 +127,11 @@
// 1. Check the topN first.
// 2. If the topN doesn't contain the value corresponding to encodedVal. We should check the histogram.
for j := 0; j < partNum; j++ {
if atomic.LoadUint32(worker.killed) == 1 {
resp.Err = errors.Trace(ErrQueryInterrupted)
worker.respCh <- resp
return
}

Check warning on line 134 in statistics/merge_worker.go

View check run for this annotation

Codecov / codecov/patch

statistics/merge_worker.go#L131-L134

Added lines #L131 - L134 were not covered by tests
if (j == i && version >= 2) || allTopNs[j].findTopN(val.Encoded) != -1 {
continue
}
Expand Down