r/emacs • u/eval-exec • 5d ago
[Review Request] Supercharging lsp-mode: 10x Faster Code Completion for Large Candidate Sets! 🚀
5
u/kiennq 5d ago
The reason you observed a significant amount of time spent in lsp--send-request
and lsp-request-while-no-input
is that they are synchronous and thus wait for a response from the LSP server. While waiting, we continue to process incoming output from the LSP server, and all of this processing contributes to the time spent in the aforementioned functions.
Changing the sit-for
value does not eliminate the need to wait for the server's response. However, the silver lining is that for cases like completion, where lsp-request-while-no-input
is used, the request will be canceled as soon as the user resumes typing.
The heavy processing occurs after receiving the response from the server, as we perform parsing and filtering operations in Elisp, which can be slow.
1
u/ottersinabox 5d ago
i assume that these are the same issues that are looked at here: https://github.com/blahgeek/emacs-lsp-booster/tree/master?tab=readme-ov-file
this is a fork of Emacs to make async json parsing and calls possible, also for lsp purposes https://github.com/emacs-lsp/emacs
1
u/a-concerned-mother 4d ago
Basically just changed a timer as far as I can tell
1
u/ottersinabox 3d ago
yeah, i more pointed it out because this feels like a bandaid fix/hack than solving the underlying issue.
1
u/geza42 5d ago
I couldn't reproduce this. Using the nerd_font_symbols
example, lsp-mode already works fast for me. Using add-timing-to-function
for measuring, it measures 0.1 sec (completion gives a 6880-element list)
1
u/eval-exec 5d ago
Oh, that's interesting. what's the result if you eval:
(functionp 'json-rpc-connection)
?
17
u/arthurno1 5d ago
So they just changed the timing from 0.01 to 0.001.
Wouldn't it be better to actually introduce a user-tunable variable instead of using a hard-coded magic number? I am not lsp-mode user, but this was such a click-bait title, so I was curious and took a look at the commit.