mirror of
https://github.com/weaveworks/scope.git
synced 2026-08-18 03:46:45 +00:00
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:
@@ -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{})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user