Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vscode with clangd on ubuntu comes to a crawl, freezes and crashes frequently #778

Open
MartyMcFlyInTheSky opened this issue Feb 19, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@MartyMcFlyInTheSky
Copy link

In our company we have a few people using ubuntu on HP laptops and when using vscode-clangd on a large codebase the application often slows down massively, oftentimes so much that it completely freezes up. During this time the CPU fan is spinning like crazy, pointing to a potential overheating issue (that might throttle the CPU). Essentially the feeling is that there are a lot of CPU cycles involved in getting the extension to work properly.

However, our other team members using MAC don't seem to have that problem (at least I never heard of them). So it seems to be kinda linux (or ubuntu) specific. I'm opening this more as collection topic to track this issue since I couldn't find it being tracked elsewhere.

System information
Clangd version (from the log, or clangd --version): 18.1.3
clangd extension version: 0.1.33
Operating system: Ubuntu 22.04

@MartyMcFlyInTheSky MartyMcFlyInTheSky added the bug Something isn't working label Feb 19, 2025
@HighCommander4
Copy link
Contributor

How big is the codebase (order of magnitude number of entries in compile_commands.json), and how much memory do the affected systems have?

Clangd's background index can use a lot of memory, so ruling out OOM / thrashing issues is a good first step.

If it really is a CPU rather than memory issue, a good diagnostic step would be to attach a debugger to the clangd process at the time of a freeze and get an all-threads backtrace, and post it for further diagnosis.

@HighCommander4
Copy link
Contributor

Oh I should also mention the -j option if you're not aware of it already:

  -j <uint>                            - Number of async workers used by clangd. Background index also uses this many workers.

Running with a lower -j than the default could help alleviate this sort of issue.

@MartyMcFlyInTheSky
Copy link
Author

In theory it's not a bad laptop - some costly hp with 14 CPU cores...
free -h shows me:

               total        used        free      shared  buff/cache   available
Mem:            30Gi       9.0Gi       6.6Gi       2.2Gi        15Gi        19Gi
Swap:          1.9Gi          0B       1.9Gi

And there are 2204 lines in my compile commands.json

I'll try to limit the number of async workers for clangd and report back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants