mirror of https://github.com/milvus-io/milvus.git
enhance: decrease CPU overhead when calculating index file size (#36579)
issue: #36578 --------- Signed-off-by: jaime <yun.zhang@zilliz.com>pull/36601/head^2
parent
4e0ea39235
commit
1fded42277
|
@ -812,6 +812,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()
|
||||
|
|
|
@ -470,18 +470,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…
Reference in New Issue