[tools] gopls/internal/test: attempt to fix BenchmarkSemanticTokens

0 views
Skip to first unread message

Gopher Robot (Gerrit)

unread,
Jun 26, 2026, 2:40:52 PM (yesterday) Jun 26
to Madeline Kalil, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, golang...@luci-project-accounts.iam.gserviceaccount.com, Alan Donovan, golang-co...@googlegroups.com

Gopher Robot submitted the change

Change information

Commit message:
gopls/internal/test: attempt to fix BenchmarkSemanticTokens

The reason we haven't been generating new benchmarks
for x/tools is that they're all failing:

https://ci.chromium.org/ui/p/golang/builders/ci/x_tools-go1.26-linux-arm64_c4as16-perf_vs_gopls_0_11?status=FAILURE

Specifically, the BenchmarkSemanticTokens is failing with:
"panic: runtime error: index out of range [17] with length 0"

https://logs.chromium.org/logs/golang/buildbucket/cr-buildbucket/8677996571488419617/+/u/step/27/log/3

The panic is coming from interpretTokens when it tries to access an
index in legend.TokenTypes. legend.TokenTypes is only empty when
SemanticTokensProvider is nil, if the editor environment is
initialized to not provide semantic tokens. However, the BenchmarkSemanticTokens
does set semanticTokens = true when calling newEnv, so this is confusing.

The benchmarks don't fail locally, so maybe there is some concurrency
issue with the env that it doesn't initialize the semantic token
provider correctly. We should call env.Close() to cleanup the env
after the benchmark run finishes. Do this in BenchmarkSemanticTokens
and also in BenchmarkDiagnosePackageFiles.

We could also make interpretTokens safer by checking if legend.TokenTypes
is empty, but I'm not sure.

For golang/go#80113
Change-Id: Ib6f63aa423508473c1a3b9a918b1f77636ef663a
Auto-Submit: Madeline Kalil <mka...@google.com>
Reviewed-by: Alan Donovan <adon...@google.com>
Files:
  • M gopls/internal/test/integration/bench/completion_test.go
  • M gopls/internal/test/integration/bench/diagnostic_test.go
  • M gopls/internal/test/integration/bench/didchange_test.go
  • M gopls/internal/test/integration/bench/imports_test.go
  • M gopls/internal/test/integration/bench/iwl_test.go
  • M gopls/internal/test/integration/bench/repo_test.go
  • M gopls/internal/test/integration/bench/semtok_test.go
Change size: S
Delta: 7 files changed, 20 insertions(+), 18 deletions(-)
Branch: refs/heads/master
Submit Requirements:
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: tools
Gerrit-Branch: master
Gerrit-Change-Id: Ib6f63aa423508473c1a3b9a918b1f77636ef663a
Gerrit-Change-Number: 794620
Gerrit-PatchSet: 5
Gerrit-Owner: Madeline Kalil <mka...@google.com>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Madeline Kalil <mka...@google.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages