mirror of
https://github.com/minio/minio.git
synced 2025-11-22 02:35:30 -05:00
fix: remove unusued PerfInfoHandler code (#9328)
- Removes PerfInfo admin API as its not OBDInfo - Keep the drive path without the metaBucket in OBD global latency map. - Remove all the unused code related to PerfInfo API - Do not redefined global mib,gib constants use humanize.MiByte and humanize.GiByte instead always
This commit is contained in:
@@ -16,10 +16,6 @@
|
||||
|
||||
package disk
|
||||
|
||||
import (
|
||||
"os"
|
||||
)
|
||||
|
||||
// Info stat fs struct is container which holds following values
|
||||
// Total - total size of the volume / disk
|
||||
// Free - free size of the volume / disk
|
||||
@@ -36,60 +32,3 @@ type Info struct {
|
||||
// Usage is calculated per tenant.
|
||||
Usage uint64
|
||||
}
|
||||
|
||||
// Performance holds informantion about read and write speed of a disk
|
||||
type Performance struct {
|
||||
Path string `json:"path"`
|
||||
Error string `json:"error,omitempty"`
|
||||
WriteSpeed float64 `json:"writeSpeed"`
|
||||
ReadSpeed float64 `json:"readSpeed"`
|
||||
}
|
||||
|
||||
// GetPerformance returns given disk's read and write performance
|
||||
func GetPerformance(path string, size int64) Performance {
|
||||
perf := Performance{}
|
||||
write, read, err := doPerfMeasure(path, size)
|
||||
if err != nil {
|
||||
perf.Error = err.Error()
|
||||
return perf
|
||||
}
|
||||
perf.WriteSpeed = write
|
||||
perf.ReadSpeed = read
|
||||
return perf
|
||||
}
|
||||
|
||||
// Calculate the write and read performance - write and read 10 tmp (1 MiB)
|
||||
// files and find the average time taken (Bytes / Sec)
|
||||
func doPerfMeasure(fsPath string, size int64) (writeSpeed, readSpeed float64, err error) {
|
||||
// Remove the file created for speed test purposes
|
||||
defer os.RemoveAll(fsPath)
|
||||
|
||||
// Create a file with O_DIRECT flag
|
||||
w, err := OpenFileDirectIO(fsPath, os.O_CREATE|os.O_WRONLY|os.O_EXCL, 0666)
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
// Fetch aligned buf for direct-io
|
||||
buf := AlignedBlock(speedTestBlockSize)
|
||||
|
||||
writeSpeed, err = speedTestWrite(w, buf, size)
|
||||
w.Close()
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
// Open file to compute read speed
|
||||
r, err := OpenFileDirectIO(fsPath, os.O_RDONLY, 0666)
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
defer r.Close()
|
||||
|
||||
readSpeed, err = speedTestRead(r, buf, size)
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
return writeSpeed, readSpeed, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user