Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/imports: should not scan bazel-out directories #35914

Open
ashi009 opened this issue Nov 30, 2019 · 3 comments
Assignees
Labels
Milestone

Comments

@ashi009
Copy link

@ashi009 ashi009 commented Nov 30, 2019

What did you do?

Open our monolith repository in VS Code, then open a go file and wait.

What did you expect to see?

Nothing.

What did you see instead?

The CPU usage goes up periodically due to gopls.

Build info

golang.org/x/tools/gopls 0.2.0
    golang.org/x/tools/gopls@v0.2.1 h1:qXHEqJw4CqROYvoDXinY1ZOkyAFS+jcPOvLRK76dvwY=
    github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
    github.com/sergi/go-diff@v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
    golang.org/x/sync@v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
    golang.org/x/tools@v0.0.0-20191108194844-46f05828f2fe h1:FNzasIzfY1IIdyTs/+o3Qv1b7YdffPbBXyjZ5VJJdIA=
    golang.org/x/xerrors@v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc=
    honnef.co/go/tools@v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM=

Go info

go version go1.13.3 darwin/amd64

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/xiaoyi/Library/Caches/go-build"
GOENV="/Users/xiaoyi/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/xiaoyi/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/xiaoyi/homebrew/Cellar/go/1.13.3/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/xiaoyi/homebrew/Cellar/go/1.13.3/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/cb/j3f4sj8j3yq46t5kqcc5mpj80000gn/T/go-build258309595=/tmp/go-build -gno-record-gcc-switches -fno-common"

VSCode settings

  "go.formatTool": "goimports",
  "go.useLanguageServer": true,
  "go.languageServerFlags": [
    "-rpc.trace",
    "serve",
    "--debug=localhost:6060",
  ],

Relevant logs

[Trace - 00:49:10.532 AM] Sending notification '$/cancelRequest'.
Params: {"id":7}


2019/12/01 00:49:24 gopathwalk: scanned /Users/xiaoyi/Projects/depot in 14.658742489s
2019/12/01 00:49:24 gopathwalk: scanning /Users/xiaoyi/go/pkg/mod
2019/12/01 00:49:24 Directory added to ignore list: /Users/xiaoyi/go/pkg/mod/cache
2019/12/01 00:49:25 gopathwalk: scanned /Users/xiaoyi/go/pkg/mod in 448.168315ms
[Trace - 00:49:27.343 AM] Received response 'textDocument/codeAction - (7)' in 17316ms.
Result: {}


2019/12/01 00:49:27 : context canceled
Params: {"type":3,"message":"2019/12/01 00:56:29 done loading package names for 10 packages"}


2019/12/01 00:56:29 gopathwalk: scanning /Users/xiaoyi/homebrew/Cellar/go/1.13.3/libexec/src
[Info  - 12:56:29 AM] 2019/12/01 00:56:29 done loading package names for 10 packages
2019/12/01 00:56:29 gopathwalk: scanned /Users/xiaoyi/homebrew/Cellar/go/1.13.3/libexec/src in 2.097875ms
2019/12/01 00:56:29 gopathwalk: scanning /Users/xiaoyi/Projects/depot
[Trace - 00:56:30.166 AM] Sending notification '$/cancelRequest'.
Params: {"type":3,"message":"2019/12/01 00:58:00 loading package names for 10 packages"}


2019/12/01 00:58:00 gopathwalk: scanning /Users/xiaoyi/homebrew/Cellar/go/1.13.3/libexec/src
[Info  - 12:58:00 AM] 2019/12/01 00:58:00 fixImports(filename="/Users/xiaoyi/Projects/depot/ecnova/tools/rebem/compgen/parser.go"), abs="/Users/xiaoyi/Projects/depot/ecnova/tools/rebem/compgen/parser.go", srcDir="/Users/xiaoyi/Projects/depot/ecnova/tools/rebem/compgen" ...
[Trace - 00:58:00.913 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2019/12/01 00:58:00 done loading package names for 10 packages"}


[Info  - 12:58:00 AM] 2019/12/01 00:58:00 loading package names for 10 packages
[Info  - 12:58:00 AM] 2019/12/01 00:58:00 done loading package names for 10 packages
2019/12/01 00:58:00 gopathwalk: scanned /Users/xiaoyi/homebrew/Cellar/go/1.13.3/libexec/src in 3.525719ms
2019/12/01 00:58:00 gopathwalk: scanning /Users/xiaoyi/Projects/depot
[Trace - 00:58:01.083 AM] Sending request 'textDocument/foldingRange - (22)'.
Params: {"textDocument":{"uri":"file:///Users/xiaoyi/Projects/depot/ecnova/tools/rebem/compgen/parser.go"}}




2019/12/01 00:58:17 gopathwalk: scanned /Users/xiaoyi/Projects/depot in 16.553269931s
2019/12/01 00:58:17 gopathwalk: scanning /Users/xiaoyi/go/pkg/mod
2019/12/01 00:58:17 Directory added to ignore list: /Users/xiaoyi/go/pkg/mod/cache
2019/12/01 00:58:17 gopathwalk: scanned /Users/xiaoyi/go/pkg/mod in 21.910985ms
[Trace - 00:58:17.518 AM] Received response 'textDocument/codeAction - (21)' in 16609ms.
Result: {}


2019/12/01 00:58:17 gopathwalk: scanning /Users/xiaoyi/homebrew/Cellar/go/1.13.3/libexec/src
[Info  - 12:58:17 AM] 2019/12/01 00:58:17 done loading package names for 10 packages
2019/12/01 00:58:17 gopathwalk: scanned /Users/xiaoyi/homebrew/Cellar/go/1.13.3/libexec/src in 25.22796ms
2019/12/01 00:58:17 gopathwalk: scanning /Users/xiaoyi/Projects/depot
2019/12/01 00:58:32 gopathwalk: scanned /Users/xiaoyi/Projects/depot in 15.012563751s
2019/12/01 00:58:32 gopathwalk: scanning /Users/xiaoyi/go/pkg/mod
2019/12/01 00:58:32 Directory added to ignore list: /Users/xiaoyi/go/pkg/mod/cache
2019/12/01 00:58:32 gopathwalk: scanned /Users/xiaoyi/go/pkg/mod in 19.820343ms
[Trace - 00:58:33.510 AM] Received response 'textDocument/codeAction - (23)' in 32367ms.
Result: {}

More Info

By inspecting the file opened by gopls, it's scanning bazel-out.

@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Nov 30, 2019

Thank you for filing a gopls issue! Please take a look at the Troubleshooting guide, and make sure that you have provided all of the relevant information here.

@gopherbot gopherbot added the gopls label Nov 30, 2019
@ashi009 ashi009 changed the title gopls: extreemly ow gopls: extremely code actions due to gopathwalk Nov 30, 2019
@odeke-em odeke-em changed the title gopls: extremely code actions due to gopathwalk x/tools/gopls: extremely code actions due to gopathwalk Dec 1, 2019
@gopherbot gopherbot added this to the Unreleased milestone Dec 1, 2019
@gopherbot gopherbot added the Tools label Dec 1, 2019
@heschik heschik changed the title x/tools/gopls: extremely code actions due to gopathwalk x/tools/imports: should not scan bazel-out directories Dec 2, 2019
@heschik

This comment has been minimized.

Copy link
Contributor

@heschik heschik commented Dec 2, 2019

I assume goimports behaves the same way, so retitling.

We don't currently support .goimportsignore in module mode. Possibly we should. See also #30058 and https://golang.org/cl/182417.

@heschik

This comment has been minimized.

Copy link
Contributor

@heschik heschik commented Dec 2, 2019

Concretely, I'd suggest that the main module, and any replace targets, could contain a .goimportsignore. Paths in that file would be processed relative to the module root or replace dir.

@vincepri, would that work for you as well? It would mean checking in a bunch of .goimportsignore files.

@stamblerre stamblerre removed the gopls label Dec 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.