Skip to content

[5.3-20201012] [completion] Filter completions on the server side #336

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

benlangmuir
Copy link
Contributor

@benlangmuir benlangmuir commented Oct 16, 2020

Cherry-pick the server-side filtering-related changes to release/5.3-20201012

rdar://69374656

benlangmuir and others added 23 commits October 16, 2020 10:54
Conflicts:
	Sources/SourceKit/CodeCompletionOptions.swift
	Sources/SourceKit/SourceKitServer.swift
	Sources/SourceKit/sourcekitd/SwiftLanguageServer.swift
Similar to cursor info, there is enough code here it makes sense to
separate it out.

Conflicts:
	Sources/SourceKit/sourcekitd/CodeCompletion.swift
	Sources/SourceKit/sourcekitd/SwiftLanguageServer.swift
Work in progress: add a basic implementation for keeping track of the
current completion session, and use the sourcekitd
complete.open/update/close requests.

Conflicts:
	Sources/SourceKit/sourcekitd/CodeCompletion.swift
	Sources/SourceKit/sourcekitd/SwiftLanguageServer.swift
With this change, tests pass whether we default to server-side or
client-side filtering. Also duplicate a few interesting tests to run
both ways. A future commit will beef up the test coverage for
server-side filtering specifically.

Conflicts:
	Sources/SourceKit/sourcekitd/SwiftLanguageServer.swift
By default, print 1-based line/column numbers using the defacto standard
line:column format. In debug print, continue to use the 0-based values
to match the constructor.
Conflicts:
	Sources/LanguageServerProtocol/SupportTypes/CodeCompletionOptions.swift
	Sources/SourceKit/CodeCompletionOptions.swift
	Sources/SourceKitLSP/CodeCompletionOptions.swift
Conflicts:
	Sources/SourceKit/SourceKitServer.swift
	Sources/SourceKit/sourcekitd/SwiftLanguageServer.swift
Since it is being used in the LSP protocol layer, give it a name that
clarifies that it is SourceKit-specific.
Conflicts:
	Sources/SourceKit/sourcekitd/CodeCompletion.swift
	Sources/SourceKit/sourcekitd/CodeCompletionSession.swift
Typically this would create a reference cycle.
We should solve this in the JSONRPCConnection itself, but in the
meantime workaround by keeping pipes alive until the connection has
closed.
When using SourceKit-LSP in tests (or otherwise in a library), we do not
want to leak the toolchain connections.

Conflicts:
	Sources/SourceKit/sourcekitd/SwiftLanguageServer.swift
…get stuck failing

- Fix for https://bugs.swift.org/browse/SR-13561 by making sure the
session close waits for the open to finish

- Add a regression test

Change-Id: Iff7217d7b03bc797e036c5329afb0765dcc1874b
…uble-dash

Change the following options to double-dash:
    --completion-max-results
    --completion-server-side-filtering

This matches the behaviour on main branch, but without pulling in the
change to use swift-argument-parser.
@benlangmuir
Copy link
Contributor Author

@swift-ci please test

@benlangmuir
Copy link
Contributor Author

  • Explanation: Code-completion server-side filtering gives a major performance improvement to completion, particularly when completing global values. For developers who import large-ish modules, this is the difference between completion being responsive and being unusably slow (several seconds per global completion).
  • Scope: Affects code-completion in sourcekit-lsp.
  • Risk: We have been using this change successfully on the main branch for a few months now, and the only impactful known issue was recently fixed and is included in this cherry-pick. If there are unanticipated regressions, command-line options can be used to revert to the old behaviour. The biggest risk is that there were many sourcekitd-related changes on main branch that we do not have on 5.3 and it is possible that in edge cases related to server shutdown we will see issues. That would most likely affect unit testing, not real users.
  • Testing: Regression tests included. Also tested manually in an editor.
  • Issue: rdar://69374656
  • Reviewer: Argyrios

@swift-ci please nominate

@svermeulen
Copy link

This is working for me. Without this, in my environment in my particular project, source kit LSP is unusably slow. With this, things seem good 👍

@benlangmuir benlangmuir merged commit fccf19f into swiftlang:release/5.3-20201012 Oct 19, 2020
@benlangmuir benlangmuir deleted the code-completion-server-side-filtering-5.3-20201012 branch October 19, 2020 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants