gopls/internal/lsp/cache: fix incorrect check for active package
Fix an embarassing oversight of CL 512636: the check for active packages
was failing deterministically.
Also update the definition benchmark to instrument CPU profiling.
Change-Id: I544da1d9395ed5eadf51338a29787e8404848347
Reviewed-on: https://go-review.googlesource.com/c/tools/+/513096
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Auto-Submit: Robert Findley <rfindley@google.com>
diff --git a/gopls/internal/lsp/cache/check.go b/gopls/internal/lsp/cache/check.go
index d96043e..c6d1344 100644
--- a/gopls/internal/lsp/cache/check.go
+++ b/gopls/internal/lsp/cache/check.go
@@ -485,7 +485,7 @@
// changes to an open package many LSP clients send several successive
// requests for package information for the modified package (semantic
// tokens, code lens, inlay hints, etc.)
- if pkg := b.activePackageCache.getActivePackage(id); ok {
+ if pkg := b.activePackageCache.getActivePackage(id); pkg != nil {
b.post(i, pkg)
return nil, nil // skip: not checked in this batch
}
diff --git a/gopls/internal/regtest/bench/definition_test.go b/gopls/internal/regtest/bench/definition_test.go
index 6479c48..b703378 100644
--- a/gopls/internal/regtest/bench/definition_test.go
+++ b/gopls/internal/regtest/bench/definition_test.go
@@ -34,6 +34,10 @@
env.GoToDefinition(loc) // pre-warm the query, and open the target file
b.ResetTimer()
+ if stopAndRecord := startProfileIfSupported(b, env, qualifiedName(test.repo, "definition")); stopAndRecord != nil {
+ defer stopAndRecord()
+ }
+
for i := 0; i < b.N; i++ {
env.GoToDefinition(loc) // pre-warm the query
}