Repository metrics
- Stars
- (133,883 stars)
- PR merge metrics
- (No merged PRs in 30d)
Description
What version of Go are you using (go version)?
1.10.3
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (go env)?
linux; amd64
What did you do?
go test --count 1 .; time go test .
foo_test.go: // package and imports snipped func TestCache(t testing.T) { tmp := os.TempDir() for i := 0; i < 101000*1000; i++ { os.Stat(filepath.Join(tmp, fmt.Sprintf("%d", i))) } }
What did you expect to see?
$ go test --count 1 .; time go test . ok github.com/dbentley/testcache 11.839s ok github.com/dbentley/testcache (cached)
real 2s
What did you see instead?
$ go test --count 1 .; time go test . ok github.com/dbentley/testcache 11.839s ok github.com/dbentley/testcache (cached)
real 1m2.278s
Further investigation
Using GODEBUG=gocachetest=1 or GODEBUG=gocachehash=1 doesn't cause output for 30+s.
I think the function inDir (currently at https://github.com/golang/go/blob/master/src/cmd/go/internal/test/test.go#L1450 ) evaluates symlinks, which requires lots of stat'ing.
It looks like this was introduced in https://github.com/golang/go/commit/37d56279c87818b496e5717bddd1f7c43bfa743d