Skip to content

Commit

Permalink
This is an automated cherry-pick of pingcap#47268
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
  • Loading branch information
hawkingrei authored and ti-chi-bot committed Dec 19, 2023
1 parent effd4c5 commit b184550
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
13 changes: 13 additions & 0 deletions pkg/executor/analyze_col_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ func (e *AnalyzeColumnsExecV2) buildSamplingStats(
e.memTracker.Consume(rootRowCollector.Base().MemSize - oldRootCollectorSize - mergeResult.collector.Base().MemSize)
mergeResult.collector.DestroyAndPutToPool()
}
<<<<<<< HEAD:pkg/executor/analyze_col_v2.go
return err
})
err = taskEg.Wait()
Expand All @@ -335,6 +336,18 @@ func (e *AnalyzeColumnsExecV2) buildSamplingStats(
err = stderrors.Join(err, err1)
}
return 0, nil, nil, nil, nil, getAnalyzePanicErr(err)
=======
oldRootCollectorSize := rootRowCollector.Base().MemSize
oldRootCollectorCount := rootRowCollector.Base().Count
// Merge the result from sub-collectors.
rootRowCollector.MergeCollector(mergeResult.collector)
newRootCollectorCount := rootRowCollector.Base().Count
printAnalyzeMergeCollectorLog(oldRootCollectorCount, newRootCollectorCount,
mergeResult.collector.Base().Count, e.tableID.TableID, e.tableID.PartitionID, e.tableID.IsPartitionTable(),
"merge subMergeWorker in AnalyzeColumnsExecV2", -1)
e.memTracker.Consume(rootRowCollector.Base().MemSize - oldRootCollectorSize - mergeResult.collector.Base().MemSize)
mergeResult.collector.DestroyAndPutToPool()
>>>>>>> 62a048c92c7 (executor: reuse fm sketch when to analyze (#47268)):executor/analyze_col_v2.go
}
err = mergeEg.Wait()
defer e.memTracker.Release(rootRowCollector.Base().MemSize)
Expand Down
11 changes: 10 additions & 1 deletion pkg/statistics/fmsketch.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,16 @@ func (s *FMSketch) MemoryUsage() (sum int64) {
}

func (s *FMSketch) reset() {
s.hashset.Clear()
// not use hashset.Clear, it will release all memory and Not conducive to memory reuse.
// the size of set is not more than 10000.
set := make([]uint64, 0, s.hashset.Count())
s.hashset.Iter(func(k uint64, v bool) (stop bool) {
set = append(set, k)
return false
})
for _, k := range set {
s.hashset.Delete(k)
}
s.mask = 0
s.maxSize = 0
}
Expand Down

0 comments on commit b184550

Please sign in to comment.