mirror of
https://github.com/minio/minio.git
synced 2024-12-24 06:05:55 -05:00
fix: for DiskInfo call cache disk metrics (#15229)
Small uploads spend a significant amount of time (~5%) fetching disk info metrics. Also maps are allocated for each call. Add a 100ms cache to disk metrics.
This commit is contained in:
parent
c7e01b139d
commit
2471bdda00
@ -78,20 +78,28 @@ type xlStorageDiskIDCheck struct {
|
||||
diskID string
|
||||
storage *xlStorage
|
||||
health *diskHealthTracker
|
||||
metricsCache timedValue
|
||||
}
|
||||
|
||||
func (p *xlStorageDiskIDCheck) getMetrics() DiskMetrics {
|
||||
diskMetric := DiskMetrics{
|
||||
APILatencies: make(map[string]uint64),
|
||||
APICalls: make(map[string]uint64),
|
||||
}
|
||||
for i, v := range p.apiLatencies {
|
||||
diskMetric.APILatencies[storageMetric(i).String()] = v.value()
|
||||
}
|
||||
for i := range p.apiCalls {
|
||||
diskMetric.APICalls[storageMetric(i).String()] = atomic.LoadUint64(&p.apiCalls[i])
|
||||
}
|
||||
return diskMetric
|
||||
p.metricsCache.Once.Do(func() {
|
||||
p.metricsCache.TTL = 100 * time.Millisecond
|
||||
p.metricsCache.Update = func() (interface{}, error) {
|
||||
diskMetric := DiskMetrics{
|
||||
APILatencies: make(map[string]uint64, len(p.apiLatencies)),
|
||||
APICalls: make(map[string]uint64, len(p.apiCalls)),
|
||||
}
|
||||
for i, v := range p.apiLatencies {
|
||||
diskMetric.APILatencies[storageMetric(i).String()] = v.value()
|
||||
}
|
||||
for i := range p.apiCalls {
|
||||
diskMetric.APICalls[storageMetric(i).String()] = atomic.LoadUint64(&p.apiCalls[i])
|
||||
}
|
||||
return diskMetric, nil
|
||||
}
|
||||
})
|
||||
m, _ := p.metricsCache.Get()
|
||||
return m.(DiskMetrics)
|
||||
}
|
||||
|
||||
type lockedLastMinuteLatency struct {
|
||||
|
Loading…
Reference in New Issue
Block a user