Go: x/tools/cmd/goimports: too slow

Created on 14 Jul 2016  ยท  7Comments  ยท  Source: golang/go

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?

go version go1.6.2 darwin/amd64

  1. What operating system and processor architecture are you using (go env)?

GOARCH="amd64" GOBIN="" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOOS="darwin" GOPATH="/Users/romeo/code/go" GORACE="" GOROOT="/usr/local/Cellar/go/1.6.2/libexec" GOTOOLDIR="/usr/local/Cellar/go/1.6.2/libexec/pkg/tool/darwin_amd64" GO15VENDOREXPERIMENT="1" CC="clang" GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common" CXX="clang++" CGO_ENABLED="1"

  1. What did you do?
    I've got a repo with a lot of vendored libraries:

```
$ tree vendor -d -L 2
vendor
โ”œโ”€โ”€ github.com
โ”‚ย ย  โ”œโ”€โ”€ BurntSushi
โ”‚ย ย  โ”œโ”€โ”€ TheThingsNetwork
โ”‚ย ย  โ”œโ”€โ”€ apex
โ”‚ย ย  โ”œโ”€โ”€ boltdb
โ”‚ย ย  โ”œโ”€โ”€ brocaar
โ”‚ย ย  โ”œโ”€โ”€ dgrijalva
โ”‚ย ย  โ”œโ”€โ”€ eclipse
โ”‚ย ย  โ”œโ”€โ”€ fsnotify
โ”‚ย ย  โ”œโ”€โ”€ golang
โ”‚ย ย  โ”œโ”€โ”€ googollee
โ”‚ย ย  โ”œโ”€โ”€ gorilla
โ”‚ย ย  โ”œโ”€โ”€ hashicorp
โ”‚ย ย  โ”œโ”€โ”€ jacobsa
โ”‚ย ย  โ”œโ”€โ”€ labstack
โ”‚ย ย  โ”œโ”€โ”€ magiconair
โ”‚ย ย  โ”œโ”€โ”€ mattn
โ”‚ย ย  โ”œโ”€โ”€ mitchellh
โ”‚ย ย  โ”œโ”€โ”€ rcrowley
โ”‚ย ย  โ”œโ”€โ”€ robertkrimen
โ”‚ย ย  โ”œโ”€โ”€ smartystreets
โ”‚ย ย  โ”œโ”€โ”€ spf13
โ”‚ย ย  โ”œโ”€โ”€ tj
โ”‚ย ย  โ””โ”€โ”€ valyala
โ”œโ”€โ”€ golang.org
โ”‚ย ย  โ””โ”€โ”€ x
โ”œโ”€โ”€ google.golang.org
โ”‚ย ย  โ”œโ”€โ”€ appengine
โ”‚ย ย  โ”œโ”€โ”€ cloud
โ”‚ย ย  โ””โ”€โ”€ grpc
โ””โ”€โ”€ gopkg.in
โ”œโ”€โ”€ bsm
โ”œโ”€โ”€ redis.v3
โ”œโ”€โ”€ sourcemap.v1
โ””โ”€โ”€ yaml.v2

35 directories
```

And now goimports is really slow:

$ time goimports routes/events.go 1>/dev/null goimports routes/events.go > /dev/null 3.45s user 9.69s system 331% cpu 3.964 total

However if I remove the vendored library and get the dependencies into my $GOPATH:

rm -r vendor go get

goimports is really fast again:

$ time goimports routes/events.go 1>/dev/null goimports routes/events.go 1>/dev/null 0.01s user 0.01s system 68% cpu 0.032 total

  1. What did you expect to see?
    Same performance on vendored libs and libs in $GOPATH.
  2. What did you see instead?
    A large performance difference.
FrozenDueToAge

Most helpful comment

Good timing. I was annoyed by goimports' performance recently and started investigating today during the Gophercon hack day. I have a change on my laptop to make things much faster.

It's doing way more work than necessary.

All 7 comments

Good timing. I was annoyed by goimports' performance recently and started investigating today during the Gophercon hack day. I have a change on my laptop to make things much faster.

It's doing way more work than necessary.

Can't wait for the CL.

CL https://golang.org/cl/24941 mentions this issue.

CL https://golang.org/cl/24948 mentions this issue.

CL https://golang.org/cl/24971 mentions this issue.

CL https://golang.org/cl/25001 mentions this issue.

I think it's fast enough to close this now.

Was this page helpful?
0 / 5 - 0 ratings