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/gopls: uses too much memory (60G) #37790

Open
bobotu opened this issue Mar 11, 2020 · 5 comments
Open

x/tools/gopls: uses too much memory (60G) #37790

bobotu opened this issue Mar 11, 2020 · 5 comments

Comments

@bobotu
Copy link

@bobotu bobotu commented Mar 11, 2020

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

$ go version
go version go1.14 linux/amd64

Does this issue reproduce with the latest release?

Yes

golang.org/x/tools/gopls v0.3.3
    golang.org/x/tools/gopls@v0.3.3 h1:mTFqRDJQmpSsgDDWvbtGnSva1z9uX2XcDszSWa6DhBQ=

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/tuzi/.cache/go-build"
GOENV="/home/tuzi/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/tuzi/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib64/go/1.14"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib64/go/1.14/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/tuzi/projects/tidb/go.mod"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build266011737=/tmp/go-build -gno-record-gcc-switches"
VS Code settings
    "go.useLanguageServer": true,
    "go.autocompleteUnimportedPackages": true,
    "go.formatTool": "goimports",
    "go.lintTool": "golangci-lint",
    "[go]": {
        "editor.formatOnSave": true,
        "editor.codeActionsOnSave": {
            "source.organizeImports": false,
        },
        // Optional: Disable snippets, as they conflict with completion ranking.
        "editor.snippetSuggestions": "none",
    },
    "[go.mod]": {
        "editor.formatOnSave": true,
        "editor.codeActionsOnSave": {
            "source.organizeImports": true,
        },
    },
    "go.languageServerExperimentalFeatures": {
        "format": false,
        "diagnostics": true,
        "documentLink": true
    },
    "go.languageServerFlags": [
        "-rpc.trace",
        "serve",
        "--debug=localhost:6060"
    ],
    "gopls": {
        // Add parameter placeholders when completing a function.
        "usePlaceholders": false,
        // If true, enable additional analyses with staticcheck.
        // Warning: This will significantly increase memory usage.
        "staticcheck": false,
    },

What did you do?

  • editor: VS Code
  • go project: pingcap/tidb
    After about half an hour, the gopls eat all of my RAM.

What did you expect to see?

Not use too many memory

What did you see instead?

atop says it has used nearly all RAM on my machine.
图片

heap profile

@gopherbot gopherbot added this to the Unreleased milestone Mar 11, 2020
@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Mar 11, 2020

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.

@ALTree ALTree changed the title x/tools/gopls: use too many memory (60G) x/tools/gopls: uses too much memory (60G) Mar 11, 2020
@heschik

This comment has been minimized.

Copy link
Contributor

@heschik heschik commented Mar 11, 2020

Thanks for the report. There should be some files named gopls.PID- in your temporary directory, named after heap sizes. Please upload the pair for the largest heap -- I would like to see a goroutine dump that matches this heap dump.

@bobotu

This comment has been minimized.

@heschik

This comment has been minimized.

Copy link
Contributor

@heschik heschik commented Mar 11, 2020

Thanks again.

I don't see any signs of a bug here but this is a massive heap. Are you using gopls in a large monorepo, or do you have huge code-generated files?

@stamblerre stamblerre modified the milestones: Unreleased, gopls/v0.4.0 Mar 11, 2020
@bobotu

This comment has been minimized.

Copy link
Author

@bobotu bobotu commented Mar 11, 2020

I'm working with TiDB codebase.
it's a huge project, some dependency may contains huge protobuf generated code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.