1
0
mirror of https://github.com/golang/go synced 2024-11-18 20:44:45 -07:00
go/internal/lsp/source
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
..
analysis.go internal/lsp: label context cancellation errors 2019-08-15 23:24:24 +00:00
completion_format.go internal/lsp: speed up deep completion search 2019-08-20 18:51:39 +00:00
completion_snippet.go internal/lsp: provide deep completion candidates 2019-06-27 18:58:03 +00:00
completion.go internal/lsp: speed up deep completion search 2019-08-20 18:51:39 +00:00
deep_completion.go internal/lsp: speed up deep completion search 2019-08-20 18:51:39 +00:00
diagnostics_test.go internal/span: change URI.Filename so it just returns the filename 2019-06-10 21:39:43 +00:00
diagnostics.go internal/lsp: abstract the diff library so it can be substituted 2019-08-20 03:37:07 +00:00
enums.go internal/lsp: switch completion item tests to using the enum strings 2019-04-17 17:57:43 +00:00
format.go internal/lsp: abstract the diff library so it can be substituted 2019-08-20 03:37:07 +00:00
highlight.go internal/lsp: split the telemetry library out 2019-08-15 21:28:02 +00:00
hover.go internal/lsp: split the telemetry library out 2019-08-15 21:28:02 +00:00
identifier.go internal/lsp: split the telemetry library out 2019-08-15 21:28:02 +00:00
imports_test.go internal/lsp: abstract the diff library so it can be substituted 2019-08-20 03:37:07 +00:00
imports.go internal/lsp: abstract the diff library so it can be substituted 2019-08-20 03:37:07 +00:00
references.go internal/lsp: split the telemetry library out 2019-08-15 21:28:02 +00:00
rename_check.go internal/lsp: use memoize package to cache source.Packages 2019-08-13 21:41:43 +00:00
rename.go internal/lsp: abstract the diff library so it can be substituted 2019-08-20 03:37:07 +00:00
signature_help.go internal/lsp: split the telemetry library out 2019-08-15 21:28:02 +00:00
source_test.go internal/lsp: abstract the diff library so it can be substituted 2019-08-20 03:37:07 +00:00
suggested_fix.go internal/lsp: abstract the diff library so it can be substituted 2019-08-20 03:37:07 +00:00
symbols.go internal/lsp: split the telemetry library out 2019-08-15 21:28:02 +00:00
util.go internal/lsp: show "do not edit" message when user opens generated file 2019-08-07 16:44:42 +00:00
view.go internal/lsp: abstract the diff library so it can be substituted 2019-08-20 03:37:07 +00:00