-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/lsp/cache: two minor optimizations
1. Avoid unnecessary intermediate map updates. 2. Avoid accumulating defers in a loop when the control is simple. Yield: -10% CPU, -37% allocs. Typical results: $ go test -v ./gopls/internal/regtest/bench -run=TestBenchmarkDidChange -didchange_dir=$HOME/w/kubernetes -didchange_file=pkg/util/hash/hash.go Before: BenchmarkStatistics 100 25932206 ns/op 11684109 B/op 75458 allocs/op After: BenchmarkStatistics 100 23294195 ns/op 11293472 B/op 47299 allocs/op Also, move profiling logic outside the loop so that later runs don't overwrite earlier runs. (This doesn't appear to be a problem in practice, presumably because the last run is the big one.) Updates golang/go#45686 Change-Id: I538ca6bb88cc18f1eefe35d2db29a62e5190280e Reviewed-on: https://go-review.googlesource.com/c/tools/+/410697 Run-TryBot: Robert Findley <rfindley@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
- Loading branch information
Showing
3 changed files
with
20 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters