Skip to content

Commit

Permalink
gopls/internal/lsp/filecache: limit Get parallelism too
Browse files Browse the repository at this point in the history
This change causes Get to be subject to the same
concurrency-limiting semaphore just added to Set, as a user
(predictably) encountered thread exhaustion
in this operation too.

Oddly, the Get benchmark doesn't seem to be limited
by the value of 128, or even smaller values.

Updates golang/go#60089

Change-Id: Ie4632cbc4cdd6536558b2067a3d115cf4fa17fae
Reviewed-on: https://go-review.googlesource.com/c/tools/+/495055
Run-TryBot: Alan Donovan <adonovan@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
  • Loading branch information
adonovan committed May 16, 2023
1 parent 7f203f0 commit 9dcd3d5
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions gopls/internal/lsp/filecache/filecache.go
Expand Up @@ -56,6 +56,9 @@ func Start() {
// possibly by another process.
// Get returns ErrNotFound if the value was not found.
func Get(kind string, key [32]byte) ([]byte, error) {
iolimit <- struct{}{} // acquire a token
defer func() { <-iolimit }() // release a token

name, err := filename(kind, key)
if err != nil {
return nil, err
Expand Down

0 comments on commit 9dcd3d5

Please sign in to comment.