Run find command with nice+ionice to reduce cpu / io

Reduce impact of running the "find" command when system is loaded. We
already use "nice" and "ionice" with the "du" command.
This commit is contained in:
Davanum Srinivas 2018-05-08 15:59:50 -04:00
parent 96b62ed83b
commit 29203d62e9

View File

@ -601,7 +601,7 @@ func GetDirInodeUsage(dir string, timeout time.Duration) (uint64, error) {
}
var counter byteCounter
var stderr bytes.Buffer
findCmd := exec.Command("find", dir, "-xdev", "-printf", ".")
findCmd := exec.Command("ionice", "-c3", "nice", "-n", "19", "find", dir, "-xdev", "-printf", ".")
findCmd.Stdout, findCmd.Stderr = &counter, &stderr
if err := findCmd.Start(); err != nil {
return 0, fmt.Errorf("failed to exec cmd %v - %v; stderr: %v", findCmd.Args, err, stderr.String())