-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
High CPU (100%+) #6894
Comments
Had this same issue last year. I haven't run into it as of late though, I'm not sure what changed |
Happy to provide any other telemetry I can to help debug this. It's not impacting my system at all other than spinning a few extra cycles. |
@noahlh I'm assuming you're opening Node.js/JavaScript projects, yes? If so, do you see the same 99% idle when you open a different project? |
@mrnugget Great suggestion - thanks.
So that's something I think...? |
Okay, interesting! That makes me think the language server might be the cause here. Do the LSP logs show anything? If you open the command palette ( Is it only with |
Thanks! Okay, culprit found, I'd say. Seems like I just created a new Svelte project (default stuff, from here: https://kit.svelte.dev/docs/creating-a-project) and it works on my machine. So now the question is: why doesn't it work on yours? I suspect it has something to do with the Tailwind language server, since that also start for JS files, but the svelte LS only for Svelte files. We log every time we start a language server via node. The logs are in here:
Does anything in these logs stand out? (You can delete them, then reproduce the issue to get new logs without having to look through them all) Also: the project you're opening -- is that public? Can I run it? If not, do you have any specific configuration for tailwind or for the tailwind language server in your project? |
Oh, and another hail mary thing: do you have any Node files in your home directory? Like |
@mrnugget I wish I had better (eg bad) news to report but those logs all look boring and clear. I'll attach the tailwind, typescript, and svelte logs here. Alas the project is not public :( But I am happy to continue to experiment and be a guinea pig to solve this. Here's all the dotfiles I have in ~/. let me know if any of these might be problematic and I can move things around if needed:
2024-02-01T02_02_18_885Z-debug-0.log |
Thanks! My current working hypothesis: we're doing something wrong when parsing log output from LSPs and somehow end up in an infinite loop, which causes the CPU usage. In order to confirm this at least somewhat, it would be great if we could disable the tailwind language server for you. Alas, we don't have a setting for that. So there's two options, as far as I can tell:
So I think for now we're stuck with (1). What do you think? |
@mrnugget Happy to try (1)! Any excuse to put my CPU cycles to good use instead of browsing random internet sites is always a bonus for me :) I shall report back once I've done this.... |
@mrnugget Ok first results -- I commented out only line 264 (tailwind tree-parser for Svelte), recompiled, opened my project, and opened a single So that doesn't appear to be it. Any other ideas? BTW - I compiled using |
Okay, I have a possible fix in here: #7229 I'm going to merge this in a minute, then you can try running on You can also comment out both language servers, just so we can see that that's not the cause. |
@mrnugget Ok confirmed the language server(s) are the issue -- I tried commenting out both lines and all good (no CPU troubles). I also tried just commenting out the Svelte language server (and not tailwind) and issue remains. So that's a good step in the right direction. Now to figure out WHY my poor little project is making the language servers so unhappy. Is there additional loggage I can check to dive in further and see why they're choking? |
Ah! Great to hear. So I think #7229 might then fix the CPU issue, but it will not fix the "language servers don't start" problem.
So you're saying that only when BOTH start up things fail?
I would assume that above the thousand lines of Other than that: most language servers have specific env vars to increase/decrease log levels. rust-analyzer, for example, takes a |
Sorry sorry I was unclear - no I meant that if either start up, CPU usage skyrockets. Only when both lines are commented out does it run smoothly. |
I was hoping that would be the case, but I was unable to find anything other than the stderrs. Not sure if the log file truncates at some point.
Ok I will explore this -- I'll see if I can get something out of the Svelte language server since I'm a bit more familiar with that ecosystem. More to come.... |
@mrnugget Small update - on my local build, I did manage to get some interesting (?) output from the tailwind language server logs:
|
Is your project really big by any chance? I do know that for some projects one needs to increase the memory limits of Node from the standard 512mb: https://gist.github.com/motss/f55b92ccab0d434fa6e6cfd07423014b I'm pretty sure #7229 will then fix the CPU issue, because it fixes the infinite |
@mrnugget I don't think so -- it's a few thousand lines of code and a few dozen I'm trying to see if I can get more debug output out of the Any hints on where/how I can enable more verbose |
I'm seeing the same thing (100% CPU usage and thousands of lines of |
@mpfaff what version of Zed are you on? Can you reproduce this with a sample Zig project? |
@noahlh sorry for dropping the ball on this! So I think what I'd try is to modify the Tailwind/Svelte language servers to run Node with some arguments. For example, here's how the zed/crates/zed/src/languages/tailwind.rs Lines 74 to 78 in 0fb6b32
And here's Svelte: zed/crates/zed/src/languages/svelte.rs Lines 72 to 76 in 0fb6b32
I'd change the code there to add the Then see if something crashes or not. |
Zed 0.121.7
I've not tried. It seems to happen only while I'm editing code, and not constantly. I would imagine it's some specific change to the file that is causing the problem, but I have no idea where to begin with testing for that. |
I cannot reproduce this. I opened the project, I ran screenshot-2024-07-04-13.58.10.mp4Even if I then open the file: I only a spike of CPU usage and then it drops back down. |
It doesn't index |
Absolutely |
Can someone reproduce this problem with language servers turned off? {
"enable_language_server": false,
} |
I have significant drop in %CPU usage. It was like 10-15, now 0.5. |
Yeah. One possible explanation for high CPU usage is that the language servers can send Zed a ton of messages, which can get CPU usage up. Example: if I restart |
@cocovs is that |
yes,CPU useage drops back down after language servers turned off |
@mrnugget - Using Zed 0.148.0 on Ubuntu 24.04, i tried this solution, for a moment it looked like it worked then went back to running high cpu % after about 5-10min of running (but not as high as before, only at about 25-55%, not 95-100% anymore) on the node process. Also running with '"enable_language_server": false' drastically dropped the cpu usage to below 1%. I took a screenshot of my culprate (while cpu usage ran high), hope it helps: |
Seems to be the tailwindcss-language-server, right? Does that mean it happens when you open a specific file? |
No it happens even on idle (i haven't work with tailwindcss in months, only php recently for converting Natural Programs to PHP). So i am not sure how to pinpoint an issue that shouldn't exist. |
Does it go away when you disable language servers, like I proposed above?
|
See my initial comment above with the screenshot (#6894 (comment)). It drastically drops the CPU usage, meaning that it runs buttery smooth. |
Argh! Sorry about that, I mixed up usernames. The project that's causing this issue is not open-source by any chance? |
No stress :). Not at all, it is completely in-house with no tailwind usage at all. Files we use are as follows and very basic (PHP, CSS, JS & HTML). I am also up to version 0.149.3, trying every day and every update to see if it gets better but no change. |
@mrnugget - I would really like to start using Zed full-time, replacing VScode but with the CPU usage issue i just can't. Please let me know what i can do to help resolve this issue. |
What I need are steps to reproduce the issue reliably. Right now I can't do much because it seems like the facts are "sometimes with some language servers CPU goes up to 100%", but that's too wide for me to dig in. |
@mrnugget I completely understand. Is there any possibility that i can only disable the tailwind language server node similarly to: If so, please advise on how to do it. |
Yeah, you can disable only Tailwind. See here: https://zed.dev/docs/configuring-languages#choosing-language-servers For example: {
"languages": {
"PHP": {
"language_servers": ["intelephense", "!phpactor", "!tailwindcss-language-server", "..."]
}
}
} That disabled |
@mrnugget Herewith my old settings.json: |
I don't see anything suspicious in there. So did disabling |
That was my problem as well, i didn't see anything strange. But no, disabling But as stated in the previous message, that solution also fixed my problem although it still jumps very high for about 1min every time i start up Zed then settles down:
|
So that means it could be another language server then, yes? When you disable tailwind, and wait until this happens, which language servers do you have running? (Open |
|
That's good, right? Or am I missing something? |
No you are correct, everything looks great. I just don't understand why, but i'm happy. Thanks a lot for your assistance throughout, i'll update again if i run into any issues. |
Check for existing issues
Describe the bug / provide steps to reproduce it
Launched Zed causes the overall process CPU usage to jump to 400% (two node subprocesses seem to be a majority of this), and then after a few minutes it settles down to 50-100% CPU usage. Not like what I'm seeing reports of 0-0.5%!
Environment
Zed: v0.119.20 (Zed)
OS: macOS 14.2.1
Memory: 64 GiB
Architecture: aarch64
If applicable, add mockups / screenshots to help explain present your vision of the feature
If applicable, attach your
~/Library/Logs/Zed/Zed.log
file to this issue.If you only need the most recent lines, you can run the
zed: open log
command palette action to see the last 1000.The text was updated successfully, but these errors were encountered: