Is my problem eglot or clangd? #1010
-
So I'm struggling with huge stalls (30-60s, sometimes more) from using eglot + clangd. I thought I had it figured out, but I guess I don't. I'm using eglot basically stock out of the box; I haven't seen anything that seems worthwhile configuring. I've turned off hover-info, and I've tried to disable flymake (it spits out mostly incorrect errors, honestly). My project is huge. It's an Unreal Engine project, and there are a lot of files. The compile_commands.json is 700+MB (most of it is flags, though, and a lot of them are duplicates), but it mostly works. clangd is currently taking up about 6GB of memory (1GB working) on my Windows 10 machine. But if I open up the events buffer, there's almost always something compiling. File after file after file, even files that haven't changed since I last saw them go by in the events buffer. I added a .clangd to my dev directory (and I believe it's being picked up; clangd uses config files by default, as near as I can tell, and I've used --check= on the command line to make sure there's nothing bad in it). Because there are so many files compiling, I thought maybe I could get around that by adding
to my .clangd file. No real change, still huge hitches all the time. FWIW, the clangd.dex file is about 315MB. I have NO idea if clangd is using it properly (if I'm honest, the clangd documentation is a nightmare; it's so bare-bones and is absolutely not helpful in a case like this). Edit:
(Does this show that the .clangd is being ignored? Diagnostics are supposed to be off.) So I suppose the question is whether this is an issue I'm having with clangd being pathological, or eglot making unnecessary requests. I love the functionality, but having the whole editor stall when I'm halfway through a line, or right after I save or any other number of somewhat random times is completely untenable, and I can't believe that this is the experience everyone else is having. I've had emacs stall while I was typing out a COMMENT in a header file. That can't possibly be normal behaviour. If anyone has any help, I'd really appreciate it. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 10 replies
-
Oh, also, I think it might be worth having an option to pause any requests while a compile is happening. I've launched a long build only to see clangd chewing through files in the background, which seems counter-productive. |
Beta Was this translation helpful? Give feedback.
-
vincentjgoh ***@***.***> writes:
So I suppose the question is whether this is an issue I'm having with
clangd being pathological, or eglot making unnecessary requests.
A poor-man's way to tell what's eating up your CPU and your time is to
glance at 'top's output on another terminal window. If you see the
'emacs' program peaking over `clangd`, then something in Emacs --
possibly but not necessarily -- Eglot, is the culprit.
Yet another way is to use M-x profiler-start, M-x profiler-stop and M-x
profiler-report and post the expanded relevant portion of the results in
this thread.
I love the functionality, but having the whole editor stall when I'm
halfway through a line, or right after I save or any other number of
somewhat random times is completely untenable, and I can't believe
that this is the experience everyone else is having. I've had emacs
stall while I was typing out a COMMENT in a header file. That can't
possibly be normal behaviour.
No, it isn't. But don't assume comments aren't somehow relevant to the
LSP server, they are. In particular, clangd can work with the
clang-tidy tool, which is generally aware of rule
activation/deactivation directives that are encoded in comments.
I use Eglot and clangd very successfully, though not with "monstruous"
projects. However, including header files with lots of templates does
mean that my compilation times are non-trivial. But my editing
experience isn't extremely degraded. And I don't turn off any default
feature of Eglot, though I do happen to use a particularly lean and
vanilla configuration.
So your problem could come down to a number of things:
* Eglot making too many requests because you've set some variable like
eglot-send-changes-idle-time or eldoc-idle-delay too low.
* You're using some other eager thing like company-mode and it also
makes "idle-time" requests in the (pseudo-)background controled by
company-idle-delay.
* The printing of log information to *EGLOT (project/c++-mode) events*
is costing a lot of time and memory. In this case you might have luck
setting eglot-events-buffer-size to 0.
* You're using some other greedy extension in Emacs, be sure to conduct
any tests using a controlled `emacs -Q` run.
As usual, the only way to tell is to conduct measurements, so be sure to
send some `M-x profiler-report` output this way.
FWIW's here's a typical profile from 2-3 minutes editing in a C++
project. As you can see Eglot's code isn't even on the map. But
c++-mode's fontification code is, though not in a show-stopping way.
c++-mode is notoriously complex and slow (and buggy), maybe someday
we'll get to replace it with something better.
João
|
Beta Was this translation helpful? Give feedback.
-
No problem. A configuration issue, as is frequent. |
Beta Was this translation helpful? Give feedback.
No problem. A configuration issue, as is frequent.