emacs-lsp / lsp-java

lsp-mode :heart: java
https://emacs-lsp.github.io/lsp-java
GNU General Public License v3.0
648 stars 90 forks source link

The completion is very slow. #400

Closed huangfeiyu closed 2 years ago

huangfeiyu commented 2 years ago

Hi, the code completion is very slow with my emacs 27.1 and jdtls 1.12. especially when I have more java file opened, it get extremely slow, I see the jdtls is quite busy during code completion, the cpu usage is quite high. Except completion, everything else like go-to-definition, works pretty fine. I've already followed the instructions from https://emacs-lsp.github.io/lsp-mode/page/performance/. Can you please tell me what I can do else to improve the completion performance? Thanks a lot!

yyoncho commented 2 years ago

I've already followed the instructions from https://emacs-lsp.github.io/lsp-mode/page/performance/.

In that same page, there is a description of how to report perf problems...

huangfeiyu commented 2 years ago

Thanks @yyoncho . Here's a report.

yyoncho commented 2 years ago

That perf report is practically useless. You have to isolate the slow behavior and expand the nodes that take time. You have expanded only the node that is related to you doing M-x profiler-stop/M-x profiler-stop which typically you should bind to something to avoid including the wait time to select command in the perf report.

yyoncho commented 2 years ago
+ timer-event-handler                                            3540  28%
+ #<compiled 0x157c971fb7a1>                                     1786  14%
+ ...                                                            1408  11%
+ redisplay_internal (C function)                                1301  10%
+ company-post-command                                            533   4%
huangfeiyu commented 2 years ago

I am sorry, @yyoncho . I'll try do it again. Not every completion is slow, it is fine sometimes, it is extremely slow another sometimes. So I am not sure if the next completion is slow or not, so I can't only include one or fewer operation to reproduce it and include it in a report. Anyway now I know how to generate a report, next time when I experience continually slow, I can generate a report.

huangfeiyu commented 2 years ago

Hi @yyoncho Here's another profiler report, please see if it help or not. Thanks

huangfeiyu commented 2 years ago

Hi @yyoncho just a reminder! Will you please check my last performance report when you get time? Thanks!

yyoncho commented 2 years ago

can you try setting lsp-java-completion-max-results to 10?

huangfeiyu commented 2 years ago

It appears fixed the slowness issue. Thank you @yyoncho !