From b822f098c557ea3d9200fd2d8a2e2b4d641e83e4 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Mon, 11 Mar 2024 20:10:48 -0700 Subject: os: don't try to make the directory FD non-blocking in os.ReadDir MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will fail because epoll_ctl() fails on directory FDs, so we end up issuing unnecessary syscalls. My test program that calls filepath.WalkDir on a large directory tree runs 1.23 ± 0.04 times faster than with the original implementation. Change-Id: Ie33d798c48057a7b2d0bacac80fcdde5b5a8bb1b Reviewed-on: https://go-review.googlesource.com/c/go/+/570877 LUCI-TryBot-Result: Go LUCI Auto-Submit: Ian Lance Taylor Reviewed-by: Ian Lance Taylor --- src/os/file_plan9.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/os/file_plan9.go') diff --git a/src/os/file_plan9.go b/src/os/file_plan9.go index 69a24316e6..477674b80a 100644 --- a/src/os/file_plan9.go +++ b/src/os/file_plan9.go @@ -139,6 +139,10 @@ func openFileNolog(name string, flag int, perm FileMode) (*File, error) { return NewFile(uintptr(fd), name), nil } +func openDirNolog(name string) (*File, error) { + return openFileNolog(name, O_RDONLY, 0) +} + // Close closes the File, rendering it unusable for I/O. // On files that support SetDeadline, any pending I/O operations will // be canceled and return immediately with an ErrClosed error. -- cgit v1.3