[tools] gopls/internal/cache: share objectpath Encoder across batch

0 views
Skip to first unread message

Alan Donovan (Gerrit)

unread,
Jun 30, 2026, 2:48:04 PM (21 hours ago) Jun 30
to goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Alex Putman, golang...@luci-project-accounts.iam.gserviceaccount.com, Hongxiang Jiang, Robert Findley, golang-co...@googlegroups.com

Alan Donovan submitted the change

Change information

Commit message:
gopls/internal/cache: share objectpath Encoder across batch

This CL causes an entire batch of type checking to share one
objectpath.Encoder. Since type checking is concurrent, this
requires serializing access to the encoder state. This could be
done by an external mutex, but it is cleaner to make Encoder
do the locking itself, since it can avoid it for most queries.

This reduces the CPU usage of objectpath.Encoder in a clean
'gopls check cmd/kubelet' from 22.0s to 10.4s.
(It was previously about 16% of total CPU; now only 9%)

Similar amortizations are applied to various batched
index construction operations such as method-sets and xrefs.

Thanks to Brian Dillmann at Cockroach Labs for the idea
(github.com/golang/tools/pull/651).
Change-Id: Ie5284e01c7ddbd28baa52281908a5deca3908003
Reviewed-by: Alex Putman <apu...@golang.org>
Files:
  • M go/types/objectpath/objectpath.go
  • M gopls/internal/cache/check.go
  • M gopls/internal/cache/methodsets/methodsets.go
  • M gopls/internal/cache/package.go
  • M gopls/internal/cache/snapshot.go
  • M gopls/internal/cache/xrefs/xrefs.go
Change size: M
Delta: 6 files changed, 35 insertions(+), 21 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: Ie5284e01c7ddbd28baa52281908a5deca3908003
Gerrit-Change-Number: 794560
Gerrit-PatchSet: 3
Gerrit-Owner: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Alex Putman <apu...@golang.org>
Gerrit-Reviewer: Hongxiang Jiang <hxj...@golang.org>
Gerrit-CC: Robert Findley <rfin...@golang.org>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages