robfig / glock

MIT License
230 stars 27 forks source link

"glock save" extremely slow on vanity import paths #25

Closed encryptio closed 8 years ago

encryptio commented 9 years ago

I have a repo (git.encryptio.com/slime) which has many subpackage imports under vanity import paths. It takes nearly a minute to run glock save git.encryptio.com/slime. glock is sending remote requests for vanity URL metadata, yet the information used by glock save to generate its output is completely local (I've written a basic script to do this for me, it finishes in 0.3 seconds and generates bit-for-bit identical output.)

This seems to stem from a non-optimized use of vcs.go's repoRootForImportPath, which runs various remote verifications to ensure proper behavior for go get (which is completely irrelevant for glock save.)

robfig commented 9 years ago

Hm, maybe the solution is as simple as using util.go:glockRepoRootForImportPath everywhere and removing the first half which uses vcs.go's version. I'd gladly accept a patch if you're interested to try it out.

Good find, thanks!

encryptio commented 9 years ago

Commenting out the call (and error handling) to vcs.go:repoRootForImportPath in util.go:glockRepoRootForImportPath fixes this particular problem and continues to generate good output.

Ran really basic tests of glock save -n and glock sync with and without changes, and they all continue to do the right thing. go test continues to pass. NB: I only have git repos referenced by this GLOCKFILE; mercurial, bazaar, and subversion support are untested.