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
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