[PATCH] D39738: [clangd] Sort completion results.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 9 14:24:38 PST 2017

sammccall added a comment.

In https://reviews.llvm.org/D39738#921103, @francisco.lopes wrote:

> I'm still in the process of construction of a general jsonrpc/LSP client and didn't start consuming clangd yet.

If you concerns about clangd's responsiveness, I recommend testing using VSCode, which has a high-quality LSP client. The clangd plugin can be installed from the extension browser.

> But, I do have previous experience with libclang, and I don't know whether clangd will be able to return completion results at global scope (not necessarily on member access solely), like libclang does.

Yes, this works today. On my usage in the LLVM codebase it's fast (~0.5 ms) but VSCode takes ~200ms to process the results, and other clients (e.g. an experimental YCMd integration) are much slower. Based on this, I'm not concerned about the server-side sorting overhead.

> This is my main concern, because global scope completion is one of the most useful use cases, even more in languages like C, but the results can be large and can go at the order of 43k results by simply including a header like windows.h <https://github.com/Valloric/YouCompleteMe/issues/2668>. As I still didn't start consuming clangd, I don't know whether it even supports returning all the results from libclang to let the client do its filtering and sorting.

This will work, but it's not really possible to make it fast. Fully populating, serializing and deserializing 43k results so the client can see them is a lot of work.
The only way to make this fast is to score and filter results before seralizing them. https://reviews.llvm.org/D39852 goes down this path. (It can be disabled if you're set on filtering client-side).



More information about the cfe-commits mailing list