From be70400fb5ac51b7fd1a02361089cb1ee79d8ce2 Mon Sep 17 00:00:00 2001 From: Mario Valderrama Date: Thu, 20 Aug 2020 16:22:00 +0200 Subject: [PATCH] etcdserver: Use Readdirnames to count fds for FDUsage Readdir already calls Readdirnames, but continues to allocate os.FileInfo with Lstat for each result. --- pkg/runtime/fds_linux.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/runtime/fds_linux.go b/pkg/runtime/fds_linux.go index 4906d678f..b5f6a7823 100644 --- a/pkg/runtime/fds_linux.go +++ b/pkg/runtime/fds_linux.go @@ -33,13 +33,12 @@ func FDUsage() (uint64, error) { } // countFiles reads the directory named by dirname and returns the count. -// This is same as stdlib "io/ioutil.ReadDir" but without sorting. func countFiles(dirname string) (uint64, error) { f, err := os.Open(dirname) if err != nil { return 0, err } - list, err := f.Readdir(-1) + list, err := f.Readdirnames(-1) f.Close() if err != nil { return 0, err