Skip to content

x/tools/cmd/goimports: too slow #16367

@romeovs

Description

@romeovs

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
    
  2. 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"
    
  3. 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
    
  4. What did you expect to see?
    Same performance on vendored libs and libs in $GOPATH.

  5. What did you see instead?
    A large performance difference.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions