1
0
mirror of https://github.com/golang/go synced 2024-11-19 00:34:40 -07:00
go/internal/lsp
Muir Manders f0be937dca internal/lsp: speed up deep completion search
Optimize a few things to speed up deep completions:

- item() is slow, so don't call it unless the candidate's name matches
  the input.
- We only end up returning the top 3 deep candidates, so skip deep
  candidates early if they are not in the top 3 scores we have seen so
  far. This greatly reduces calls to item(), but also avoids a
  humongous sort in lsp/completion.go.
- Get rid of error return value from found(). Nothing checked for this
  error, and we spent a lot of time allocating the only possible error
  "this candidate is not accessible", which is not unexpected to begin
  with.
- Cache the call to types.NewMethodSet in methodsAndFields(). This is
  relatively expensive and can be called many times for the same type
  when searching for deep completions.
- Avoid calling deepState.chainString() twice by calling it once and
  storing the result on the candidate.

These optimizations sped up my slow completion from 1.5s to
0.5s. There were around 200k deep candidates examined for this one
completion. The remaining time is dominated by the fuzzy
matcher. Obviously 500ms is still unacceptable under any
circumstances, so there will be subsequent improvements to limit the
deep completion search scope to make sure we always return completions
in a reasonable amount of time.

I also made it so there is always a "matcher" set on the
completer. This makes the matching logic a bit simpler.

Change-Id: Id48ef7031ee1d4ea04515c828277384562b988a8
Reviewed-on: https://go-review.googlesource.com/c/tools/+/190522
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-08-20 18:51:39 +00:00
..
browser internal/lsp: add version and bug commands 2019-05-11 04:16:02 +00:00
cache internal/lsp: label context cancellation errors 2019-08-15 23:24:24 +00:00
cmd internal/lsp: abstract the diff library so it can be substituted 2019-08-20 03:37:07 +00:00
debug internal/telemetry: change concurrency model 2019-08-20 03:27:56 +00:00
diff internal/lsp: abstract the diff library so it can be substituted 2019-08-20 03:37:07 +00:00
fuzzy internal/lsp: add fuzzy completion matching 2019-08-14 16:13:50 +00:00
protocol internal/lsp: use protocol.Range for diagnostics instead of span.Span 2019-08-16 17:06:24 +00:00
snippet internal/lsp: introduce snippet builder object 2019-04-25 18:37:29 +00:00
source internal/lsp: speed up deep completion search 2019-08-20 18:51:39 +00:00
telemetry internal/telemetry: extract units to their own package 2019-08-15 21:28:32 +00:00
testdata internal/lsp: add completions of unimported std lib pkgs 2019-08-16 18:32:40 +00:00
tests internal/lsp: add completions of unimported std lib pkgs 2019-08-16 18:32:40 +00:00
code_action.go internal/lsp: separate out getMapper function 2019-08-16 20:05:58 +00:00
completion.go internal/lsp: speed up deep completion search 2019-08-20 18:51:39 +00:00
definition.go internal/lsp: separate out getMapper function 2019-08-16 20:05:58 +00:00
diagnostics.go internal/lsp: separate out getMapper function 2019-08-16 20:05:58 +00:00
format.go internal/lsp: abstract the diff library so it can be substituted 2019-08-20 03:37:07 +00:00
general.go internal/lsp: add completions of unimported std lib pkgs 2019-08-16 18:32:40 +00:00
highlight.go internal/lsp: separate out getMapper function 2019-08-16 20:05:58 +00:00
hover.go internal/lsp: separate out getMapper function 2019-08-16 20:05:58 +00:00
link.go internal/lsp: separate out getMapper function 2019-08-16 20:05:58 +00:00
lsp_test.go internal/lsp: abstract the diff library so it can be substituted 2019-08-20 03:37:07 +00:00
references.go internal/lsp: separate out getMapper function 2019-08-16 20:05:58 +00:00
rename.go internal/lsp: separate out getMapper function 2019-08-16 20:05:58 +00:00
reset_golden.sh internal/lsp: fix definition tests to use golden files 2019-05-10 21:06:55 +00:00
server.go internal/lsp: add completions of unimported std lib pkgs 2019-08-16 18:32:40 +00:00
signature_help.go internal/lsp: separate out getMapper function 2019-08-16 20:05:58 +00:00
symbols.go internal/lsp: separate out getMapper function 2019-08-16 20:05:58 +00:00
text_synchronization.go internal/lsp: separate out getMapper function 2019-08-16 20:05:58 +00:00
util.go internal/lsp: separate out getMapper function 2019-08-16 20:05:58 +00:00
workspace.go internal/lsp: use x/xerrors to create new errors 2019-08-06 19:46:56 +00:00