Sarcasm / irony-mode

A C/C++ minor mode for Emacs powered by libclang
GNU General Public License v3.0
901 stars 98 forks source link

High completion latency when working with large codebase #409

Open amol-mandhane opened 6 years ago

amol-mandhane commented 6 years ago

I'm using irony-mode with a huge codebase (O(100k) header files) on a linux machine. Completion quality is quite good but the latency for suggesting completion is 4-5 seconds, which makes it difficult to use irony-mode with company-irony.

Is there any way to improve the completion performance? From my CPU usage, irony-mode seems to be using one thread for completion. Multithreading can be a good way to improve the performance. The code indexing can be done in the background thread and completion lookup can be done on request thread. Or simply the completion lookup can be parallelized.

Sarcasm commented 6 years ago

irony-server uses libclang for completion. EIther I'm misusing the API or the operation is simply slow in libclang. Either way, if the solution is multithreading or any other smart indexing, it is out of the league for irony-server.

The next step in this direction would be clangd in my opinion: https://github.com/llvm-mirror/clang-tools-extra/tree/master/clangd

Which I'm not sure is easy to use with Emacs yet.

kangjianbin commented 6 years ago

I guess the reason might be libclang outputs too many candidates. Is it possible to pass 'prefix' parameter to irony-server and filter the complete result in irony-server?

Sarcasm commented 6 years ago

Is it possible to pass 'prefix' parameter to irony-server and filter the complete result in irony-server?

It is technically possible, and I had a refactoring "somewhat recently" to allow to add more commands. Prefix filtering (fuzzy or not) was one of the use case I had in mind. So the only thing required is to code it, which I don't plan to do anytime soon but would be happy to give guidance/review.

kangjianbin commented 6 years ago

Hi Saracasm, I just created a pull request #412 to support the filtering. We still need to modify company-irony to support it. I will send other request if #412 is accepted.

Any suggestions?