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: Using memory for unknown reason #44994

Closed
dragonly opened this issue Mar 14, 2021 · 2 comments
Closed

x/tools/gopls: Using memory for unknown reason #44994

dragonly opened this issue Mar 14, 2021 · 2 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@dragonly
Copy link

dragonly commented Mar 14, 2021

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

$ go version
go version go1.16 darwin/arm64

Does this issue reproduce with the latest release?

$ gopls version
golang.org/x/tools/gopls v0.6.6
    golang.org/x/tools/gopls@v0.6.6 h1:GmCsAKZMEb1BD1BTWnQrMyx4FmNThlEsmuFiJbLBXio=

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

go env Output
$ go env
GO111MODULE=""
GOARCH="arm64"
GOBIN="/Users/dragonly/go/bin"
GOCACHE="/Users/dragonly/Library/Caches/go-build"
GOENV="/Users/dragonly/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/dragonly/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/dragonly/go"
GOPRIVATE=""
GOPROXY="https://goproxy.io,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.16"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/pv/cqn4jtrj1kg6fwxwk31j9z1w0000gn/T/go-build348655080=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

profile gopls heap usage

What did you expect to see?

the same usage as system monitor

What did you see instead?

There's an 1G gap between the profile and the system monitor result.
image

@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Mar 14, 2021
@gopherbot gopherbot added this to the Unreleased milestone Mar 14, 2021
@D1CED
Copy link

D1CED commented Mar 14, 2021

What you are looking at are two very different kinds of metrics. gopls is showing you the sum of allocated memory of all live objects in your processes heap while your system monitor is likely showing RSS.
You can not expect any relation between these two numbers.

Reasons why RSS can be larger than live object memory sum

  • the page allocator holds reserves
  • the regular allocator holds reserves (each size class and each thread)
  • there are off (main-)heap resources
  • fragmentation
  • there may be memory not reclaimed by the os (see madvfree)
  • any tracing based garbage collected runtime will hold significant memory reserves (see GOGC)

Reasons why live object memory sum can be larger than RSS

  • there can be a large amount of static objects (they are not part of RSS)
  • pages might be swapped
  • pages might be deduplicated by the os (for e.g. linux uses copy-on-write when forking)

@mdlayher
Copy link
Member

See above, I don't think there is anything actionable here. Closing.

@golang golang locked and limited conversation to collaborators Mar 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants