mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-02-02 01:06:41 +08:00
enhance: decrease CPU overhead when calculating index file size (#36580)
issue: #36578 pr: #36579 Signed-off-by: jaime <yun.zhang@zilliz.com>
This commit is contained in:
parent
86004d852e
commit
bf671786d9
@ -789,6 +789,25 @@ func (m *indexMeta) GetAllSegIndexes() map[int64]*model.SegmentIndex {
|
||||
return segIndexes
|
||||
}
|
||||
|
||||
// SetStoredIndexFileSizeMetric returns the total index files size of all segment for each collection.
|
||||
func (m *indexMeta) SetStoredIndexFileSizeMetric(collections map[UniqueID]*collectionInfo) uint64 {
|
||||
m.RLock()
|
||||
defer m.RUnlock()
|
||||
|
||||
var total uint64
|
||||
metrics.DataCoordStoredIndexFilesSize.Reset()
|
||||
|
||||
for _, segmentIdx := range m.buildID2SegmentIndex {
|
||||
coll, ok := collections[segmentIdx.CollectionID]
|
||||
if ok {
|
||||
metrics.DataCoordStoredIndexFilesSize.WithLabelValues(coll.DatabaseName,
|
||||
fmt.Sprint(segmentIdx.CollectionID), fmt.Sprint(segmentIdx.SegmentID)).Set(float64(segmentIdx.IndexSize))
|
||||
total += segmentIdx.IndexSize
|
||||
}
|
||||
}
|
||||
return total
|
||||
}
|
||||
|
||||
func (m *indexMeta) RemoveSegmentIndex(collID, partID, segID, indexID, buildID UniqueID) error {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
|
||||
@ -462,18 +462,7 @@ func (m *meta) GetQuotaInfo() *metricsinfo.DataCoordQuotaMetrics {
|
||||
func (m *meta) SetStoredIndexFileSizeMetric() uint64 {
|
||||
m.RLock()
|
||||
defer m.RUnlock()
|
||||
var total uint64
|
||||
|
||||
metrics.DataCoordStoredIndexFilesSize.Reset()
|
||||
for _, segmentIdx := range m.indexMeta.GetAllSegIndexes() {
|
||||
coll, ok := m.collections[segmentIdx.CollectionID]
|
||||
if ok {
|
||||
metrics.DataCoordStoredIndexFilesSize.WithLabelValues(coll.DatabaseName,
|
||||
fmt.Sprint(segmentIdx.CollectionID), fmt.Sprint(segmentIdx.SegmentID)).Set(float64(segmentIdx.IndexSize))
|
||||
total += segmentIdx.IndexSize
|
||||
}
|
||||
}
|
||||
return total
|
||||
return m.indexMeta.SetStoredIndexFileSizeMetric(m.collections)
|
||||
}
|
||||
|
||||
func (m *meta) GetAllCollectionNumRows() map[int64]int64 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user