Closed dmitshur closed 8 years ago
SGTM.
This is especially bad with on OS X with its shitty VFS.
I get:
bradfitz@laptop ~$ time go list all
....
real 1m19.141s
user 0m6.622s
sys 0m6.329s
And on the second run:
real 0m20.448s
user 0m5.820s
sys 0m4.794s
(Where Linux is 5 seconds on the second run.)
But both 5 secondsand 22 seconds are both slow.
Done. Thanks.
(I'm reporting this issue, but no PR because it's not feasible to make a PR to resolve this. Only you, @bradfitz, the owner of this repo, can resolve this. It's easy.)
Problem
Having this repository inside my GOPATH workspace makes operations such as
go list all
orgo list .../foo/bar
much, much slower, needlessly.I have a moderate/large amount of Go packages in my GOPATH (around 2000), and I have an SSD. With
go-issue-mirror
repository as is, doinggo list all
takes 8-10 seconds:With a simple change I propose below in "Solution" section, that time can be restored to a much more reasonable 2.5~ seconds.
go list all
is just an example. It also affects queries such as.../foo/bar
, which I use very often to navigate to specific Go packages.Cause
The
cmd/go
command scans the GOPATH workspace(s) each time to find Go packages. It goes over all folders, and checks if they have .go files (i.e. it checks ifbuild.ImportDir
successfully finds a package).The issues directory in this repository contains a single Go package, but it also has 1000 directories, each with many more directories and files.
We as humans know it's a waste of time looking for Go packages inside, but the
cmd/go
tool doesn't. It needs a hint.Solution
Luckily, it supports such hints:
Using "." is not a good idea because it'll make the folder hidden. "testdata" isn't a great fit since this is just real "data", not "data for tests". But you can prepend the folder with an underscore, and
cmd/go
will know to skip it and not waste time scanning all those directories/files.I usually name such folders
_data
(it's like testdata, except not for tests, and starts with_
). E.g.:So, if I move all of issues subfolders into a directory named
_data
, then it becomes 2.5 seconds:I know you use
github.com/bradfitz/go-issue-mirror/issues
import path to find the issues "data". You can move all that issues data into_data
subfolder:And keep
issues.go
insidegithub.com/bradfitz/go-issue-mirror/issues
as is, just modify issues.go#L18 to point to the new subdirectory.Anyway, how exactly you resolve this is up to you, but please fix it... I am sad when Go is unnecessarily slow. :(