mirror of https://github.com/golang/go.git
This change replaces the single large map used for snapshot.goFiles by a map of 256 stripes, each of which becomes immutable once shared. This optimizes the common case in which the copy is nearly identical to the original. We still need to visit each map entry to see whether it needs to be deleted (which is rare) and to inherit the handle in the usual case. This is now done concurrently. Also, share the (logically immutable) []PackageIDs slices across old and new snapshots. This was worth 5% of CPU and 1/3 of allocations (all small). Benchmark on darwin/arm64 shows a 29% reduction for DidChange. $ go test -v ./gopls/internal/regtest/bench -run=TestBenchmarkDidChange -didchange_dir=$HOME/w/kubernetes -didchange_file=pkg/util/hash/hash.go Before: BenchmarkStatistics 100 22955469 ns/op 11308095 B/op 47412 allocs/op BenchmarkStatistics 100 23454630 ns/op 11226742 B/op 46882 allocs/op BenchmarkStatistics 100 23618532 ns/op 11258619 B/op 47068 allocs/op After goFilesMap: BenchmarkStatistics 100 16643972 ns/op 8770787 B/op 46238 allocs/op BenchmarkStatistics 100 17805864 ns/op 8862926 B/op 46762 allocs/op BenchmarkStatistics 100 18618255 ns/op 9308864 B/op 49776 allocs/op After goFilesMap and ids sharing: BenchmarkStatistics 100 16703623 ns/op 8772626 B/op 33812 allocs/op BenchmarkStatistics 100 16927378 ns/op 8529491 B/op 32328 allocs/op BenchmarkStatistics 100 16632762 ns/op 8557533 B/op 32497 allocs/op Also: - Add comments documenting findings of profiling. - preallocate slice for knownSubdirs. - remove unwanted loop over slice in Generation.Inherit Updates golang/go#45686 Change-Id: Id953699191b8404cf36ba3a7ab9cd78b1d19c0a2 Reviewed-on: https://go-review.googlesource.com/c/tools/+/410176 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> Run-TryBot: Alan Donovan <adonovan@google.com> |
||
|---|---|---|
| .. | ||
| analysis | ||
| browser | ||
| bug | ||
| cache | ||
| cmd | ||
| command | ||
| debug | ||
| diff | ||
| fake | ||
| fuzzy | ||
| helper | ||
| lsppos | ||
| lsprpc | ||
| mod | ||
| progress | ||
| protocol | ||
| regtest | ||
| safetoken | ||
| snippet | ||
| source | ||
| template | ||
| testdata | ||
| tests | ||
| work | ||
| README.md | ||
| call_hierarchy.go | ||
| code_action.go | ||
| code_lens.go | ||
| command.go | ||
| completion.go | ||
| completion_test.go | ||
| debounce.go | ||
| debounce_test.go | ||
| definition.go | ||
| diagnostics.go | ||
| folding_range.go | ||
| format.go | ||
| general.go | ||
| highlight.go | ||
| hover.go | ||
| implementation.go | ||
| link.go | ||
| lsp_test.go | ||
| references.go | ||
| rename.go | ||
| reset_golden.sh | ||
| semantic.go | ||
| server.go | ||
| server_gen.go | ||
| signature_help.go | ||
| symbols.go | ||
| text_synchronization.go | ||
| workspace.go | ||
| workspace_symbol.go | ||
README.md
lsp
internal/lsp provides much of the Language Server Protocol (lsp) implementation for gopls.
Documentation for users and contributors can be found in the
gopls/doc directory.