]> Cypherpunks repositories - gostls13.git/commit
os: reduce allocations in Readdir on unix
authorTaru Karttunen <taruti@taruti.net>
Wed, 28 Oct 2015 10:58:58 +0000 (12:58 +0200)
committerBrad Fitzpatrick <bradfitz@golang.org>
Fri, 30 Oct 2015 19:47:55 +0000 (19:47 +0000)
commitf5f480e1df6b394ebc71eb3c1ba2b4c91c232425
tree61e1a0544abcb5227cf14cbdafd3c1f52a08f8be
parenta21b4bca0c82098f3a445d663365c9afea8fa699
os: reduce allocations in Readdir on unix

Include syscall.Stat_t on unix to the
unexported fileStat structure rather than
accessing it though an interface.

Additionally add a benchmark for Readdir
(and Readdirnames).

Tested on linux, freebsd, netbsd, openbsd
darwin, solaris, does not touch windows
stuff. Does not change the API, as
discussed on golang-dev.

E.g. on linux/amd64 with a directory of 65 files:

benchmark              old ns/op     new ns/op     delta
BenchmarkReaddir-4     67774         66225         -2.29%

benchmark              old allocs     new allocs     delta
BenchmarkReaddir-4     334            269            -19.46%

benchmark              old bytes     new bytes     delta
BenchmarkReaddir-4     25208         24168         -4.13%

Change-Id: I44ef72a04ad7055523a980f29aa11122040ae8fe
Reviewed-on: https://go-review.googlesource.com/16423
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
12 files changed:
src/os/file_unix.go
src/os/os_test.go
src/os/stat_darwin.go
src/os/stat_dragonfly.go
src/os/stat_freebsd.go
src/os/stat_linux.go
src/os/stat_nacl.go
src/os/stat_netbsd.go
src/os/stat_openbsd.go
src/os/stat_solaris.go
src/os/types_plan9.go [moved from src/os/types_notwin.go with 93% similarity]
src/os/types_unix.go [new file with mode: 0644]