Sourcekit LSP completion delay with sublime text

Hello. I have some lagging of the first autocompletion while using Sourcekit-LSP with Sublime Text, which is happens with the Sourcekit-LSP server elusively .

When I'm starting to type something within the function on the new line, like re for predefined request object. The completion hangs for about 3-4 seconds to get some results. After typing next letters within the same word, like req completion works with almost no delay.

So I'd try to figure out what causes such behavior and enable the debug logging of the LSP and got log file for 12.8 MB for exact same workflow that I'd mention above while it have only 51 lines.

So I wonder, maybe is it the cause of the delay with the new word rather is it the LSP client problem?

log file

Note: when you go from "re" to "req" inside the same word it is not calculating completions again, just filtering them.

Could you clarify: does it happen every time you are completing in a new identifier? Or is it only the first time after you open the file? And does it only happen for global completion, or does it also happen when completing members (after a ".")?

It happens every time when I'm typing new identifier. e.g. if I'm type "request" several times each on the new line in a same file it will stuck on each of them the same.

It don't hangs such when completing members (after a "."). The hang there is about a fraction of a second, so it's ok.

Also I can update my first issue: the hang (at least with there req part) happened about 2 seconds (I've check it with the chronograph), so it's no so terribly bad, but quite annoying to use it for development.

Here the part of the code where it happens.

var request = URLRequest(url: url)
request.httpMethod = RequestMethod.get.rawValue

req

Also I can update my first issue: the hang (at least with there req part) happened about 2 seconds (I've check it with the chronograph),

Okay thanks! Looking at your log, there are about 32,600 global results. This is a known performance problem in SourceKit-LSP caused by serialization performance to JSON. Our plan to tackle this is to implement server-side filtering for completions so that we do not have to serialize all of the results.

it's no so terribly bad, but quite annoying to use it for development.

This is an important area for us to improve, because it's easy to hit cases with this many global results when importing SDK modules.

Got it, thank you!

I have implemented server-side filtering for you guys
The OS X binary and source codes can be find here

2 Likes

I tried this fork and the sourcekit-lsp server crashed a bunch on vscode + sublime even with a simple 'hello world' program :cry:

I use it everyday without any problems. I use it on vscode with SDE extension.

Please be aware that the extension requires configuration. If you don't configure it, it will definitely crash.

I don't use sublime, so I don't know what will happen.

Now fixed in master branch: Code-completion performance improvement via server-side filtering

1 Like