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: workspace/symbol response doesn't conform to spec when sending an empty query #47655

Closed
mohkale opened this issue Aug 11, 2021 · 3 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

@mohkale
Copy link

mohkale commented Aug 11, 2021

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

$ go version
go version go1.16.6 linux/amd64

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/mohkale/.cache/go-build"
GOENV="/home/mohkale/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/mohkale/prog/.modules/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/mohkale/prog/.modules/go:"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.16.6"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
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 -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1016297562=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I had my LSP client send a workspace/symbols request to gopls with an empty query string.

What did you expect to see?

It to return all the symbols in the workspace (as it is supposed to according to the protocol specification).

What did you see instead?

The server returned no symbols.

@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 Aug 11, 2021
@gopherbot gopherbot added this to the Unreleased milestone Aug 11, 2021
@findleyr
Copy link
Contributor

findleyr commented Aug 11, 2021

FTR, gopls also restricts to the top 100 results, which per this reading of the spec is also not conformant.

Note that there are a lot of symbols in a workspace. For Kubernetes, gopls has around 30mb of symbols in a minimal representation; when expanded with qualified paths and the full symbol struct, it could easily be 100mb+ of data. Furthermore, restricting to the top 100 results allows some not insignificant optimizations for all queries: gopls can avoid allocating results if the score is too low to make the top results list.

I just landed a sequence of optimizations (not yet released), that reduces query latency in Kubernetes from 2-3s down to around 50-100ms, and from my experimentation having very low latency significantly improves the user experience. I'd hate to sacrifice that in the name of conformance.

Why do you want too see all symbols?

@mohkale
Copy link
Author

mohkale commented Aug 11, 2021

@findleyr

Why do you want too see all symbols?

I was just experimenting with a frontend interface for LSP and gopls was one of the few servers that supported the workspace/symbol request which lead me to find this. Given the massive search space of available symbols I guess it makes sense to not return anything with an empty query.

I just raised the issue because it didn't seem like there was one yet. If you feel the lack of compliance here is OK please feel free to close it. Thank you.

@findleyr
Copy link
Contributor

Thanks.

You're right that gopls is not conformant to the spec, unless we use a very generous reading that the client 'may request' but the server may choose how to satisfy that request.

But IMO the outcome of conforming to the spec here would be at best a footgun, and at worst a degraded experience for most users. This has come up before, but I'm not aware of any concrete reason to ask for all symbols.

The one reason I've heard is that in some UIs it's strange to open workspace symbols and get empty results. Maybe we should consider returning the top 100 symbols for an empty query.

Anyway, closing for now. If anyone wants to revisit this we can reopen.

@golang golang locked and limited conversation to collaborators Aug 11, 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

3 participants