Skip to content

x/tools/gopls: handle (some) requests asynchronously #69937

Closed
@findleyr

Description

@findleyr

While gopls performs some background operations such as producing diagnostics asynchronously, it has never handled jsonrpc2 requests asynchronously. In the past, this didn't matter much, because the bulk of request handling was type checking, and type checked open packages are memoized, so typically the first request would be slow, but subsequent requests would be fast.

However, there have always been areas where true concurrent request handling would be helpful, and recently we've added a couple more:

We should make gopls concurrent. In order for this to work, we need jsonrpc2 APIs that delegate control over concurrent handling to the core of gopls (not the RPC layer), because gopls needs to start handling the request (acquiring a Snapshot) before the next request may proceed, in order to preserve the logical ordering of requests.

Eventually, we should do this with the new jsonrpc2_v2 library, which has better APIs for handler binding, and will result in a cleaner overall result. However, @adonovan and I were discussing, and he pointed out that we can use a trick similar to t.Parallel to "release" requests, allowing concurrency to be implemented with minimal API change.

Metadata

Metadata

Assignees

Labels

ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions