• Taru Karttunen's avatar
    os: reduce allocations in Readdir on unix · f5f480e1
    Taru Karttunen authored
    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/16423Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
    Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    f5f480e1
stat_openbsd.go 1.17 KB