summaryrefslogtreecommitdiff
path: root/python/binary.go
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2017-12-21 16:44:26 -0800
committerColin Cross <ccross@android.com>2017-12-22 13:56:17 -0800
commitae7fd6baf3ffdddf498eedfe598d403f8570b31a (patch)
treee8d1a8f7a2b71625f56fff048092dc9629d288fe /python/binary.go
parenta88c883e3efc19ba677c8bcca65fce73d057ada7 (diff)
Reimplement ioutil.ReadDir with a version that avoids calling lstat
ioutil.ReadDir returns []os.FileInfo, which contains information on each entry in the directory that is only available by calling os.Lstat on the entry. Finder only the name and type (regular, directory or symlink) of the files, which on Linux kernels >= 2.6.4 is available in the return values of syscall.Getdents. Replace ioutil.ReadDir with a call that uses syscall.Getdents directly and collects the type information from the result. Testing with: rm -f /tmp/db && strace -fc finder -names Android.mk,Android.bp,Blueprints,CleanSpec.mk,TEST_MAPPING -exclude-dirs .git,.repo -prune-files .out-dir,.find-ignore -db /tmp/db . Before: 7.01 52.688304 63 833398 1 lstat 1.90 14.246644 68 210523 getdents64 1.25 9.370471 90 104286 1 openat After: 3.48 12.201385 117 104286 1 openat 3.06 10.729138 51 210523 getdents64 1.70 5.951892 57 104283 1 lstat Pros: Avoids 729115 calls to lstat. Cons: Requires copying ~200 lines of finicky buffer parsing code. Puts all getdents calls (and possibly fallback lstat calls) onto a non-blocking file descriptor, which will cause it to block a thread and not just a goroutine. Only works on Linux and Darwin. Bug: 70897635 Test: m checkbuild Change-Id: Iab9f82c38c8675d0b73b4e90540bb9e4d2ee52c1
Diffstat (limited to 'python/binary.go')
0 files changed, 0 insertions, 0 deletions