proc walker: optimize open file counter

Golang's ReadDirNames is expensive and better avoided when we don't care
about the names.
This commit is contained in:
Alban Crequy
2017-05-02 14:45:12 +02:00
parent c6a299402c
commit 640b240469
+2 -2
View File
@@ -102,7 +102,7 @@ func (w *walker) Walk(f func(Process, Process)) error {
continue
}
openFiles, err := fs.ReadDirNames(path.Join(w.procRoot, filename, "fd"))
openFilesCount, err := fs.ReadDirCount(path.Join(w.procRoot, filename, "fd"))
if err != nil {
continue
}
@@ -139,7 +139,7 @@ func (w *walker) Walk(f func(Process, Process)) error {
Jiffies: jiffies,
RSSBytes: rss,
RSSBytesLimit: rssLimit,
OpenFilesCount: len(openFiles),
OpenFilesCount: openFilesCount,
OpenFilesLimit: openFilesLimit,
}, Process{})
}