eranif / codelite

A multi purpose IDE specialized in C/C++/Rust/Python/PHP and Node.js. Written in C++
https://codelite.org
GNU General Public License v2.0
2.08k stars 444 forks source link

[Bug]: Clangd slow for large files above 1000 lines #3362

Closed shadoww1028 closed 1 week ago

shadoww1028 commented 1 month ago

What happened?

On Linux mint 21.3 Clangd is a nice tool to use but in large files, when show diagnostics is checked, the editor can be very slow. If a word is typed it may show up 5 seconds later. One way I would look into fixing this is to not fire clangd checks right away but wait until the typing stops or have a timeout. Codelite 17.9. Other than that clangd works well it just this one major issue that is hard to fix that stands in the way.

Workaround: turn off show Diagnostics while editing then turn them on and clean up.

Version

Other

Operating system

Linux

Steps to reproduce

Get a large code file and start typing.

Relevant log output

none
eranif commented 1 month ago

CodeLite is currently uses the LSP model of "Publish diagnostics" i.e. it does not request them - the server sends them whenever it sees fit. A new concept was introduced: "Pull diagnostics". This should be the preferred approach. However, I don't think that most of the LSPs support this.

https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_pullDiagnostics I will need to check with clangd and see if this is supported

eranif commented 1 month ago

I did a quick check: clangd version 17.0.6 does not support this feature. Quick question: you mentioned that Disabling the "Display diagnostics" check box is a workaround. But this only affects the UI and not the communication with the server (i.e. diagnostics are still being received by CodeLite) so this might indicate an issue with adding the markers images and not with manipulating the actual data. So the question is: when editing large files, how many markers do you get in the editor?

eranif commented 1 month ago

You forgot to mention your CodeLite version.

This commit should have reduced the work done when placing diagnostic markers: 13f3e95fcaece62f0f2ac50643d94b57c818fbde

shadoww1028 commented 1 week ago

After getting the latest from git, the deb seems to be 17.9.0 still I can say that this bug is indeed fixed. Marked version 17.11.0 at the time of writing. I was using 17.1.0 I think sorry about the version mismatch.

shadoww1028 commented 1 week ago

I have to say that this improvement really fixed a lot of things. The debugger is faster, typing is faster just about everything is faster now. Alot more usable now, Thanks.