-
Notifications
You must be signed in to change notification settings - Fork 180
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 usage by terraform-ls serve
on save+format
#1328
Comments
This started happening to me recently as well, and it's not just format-on-save. Whenever I start typing, it takes a second for code to syntax-check each newly written character. I can see it moving slowly because it adds a squiggly red line to each character, one-by-one, at a snail's pace. |
Adding my own experience here.
I find that upon opening VSCode, the plugin seems to walk every directory recursively, and also kick off a job which spews hundreds of thousands of lines containing Another note, I have seen this behavior with both the "mainline" and "preview" versions of this extension. Similar to OP, I have tried updating VSC multiple times, enabling and disabling the extension, trying the preview vs main versions, rebooting, adding folders to the exclusion list of the extension (which it seems needs an exact match and isn't globbing or wildcarding? That's near impossible for me to even try to attempt to add to my config to exclude dirs to walk.) VS Code Info:
|
Sorry for a second comment directly following my first, could this be related to the problems noted in this issue -> hashicorp/terraform-ls#1100 ? |
Could be. Personally I found my issue was directly related to the |
FWIW, I just tested/am testing right now. Disabled all "Codelens Reference Count" settings in VSC (including non-Terraform related options) This is anecdotal and my only attempt at reloading/using/etc VSC since trying your suggestion @smiller171, but I thought I'd throw it in. |
Facing the same issue with HashiCorp Terraform v2.25.4. My MacOS is unusable while terraform-ls run in background. |
Thank you for taking the time to report this issue. We released the new extension 2.26.0 version (and 0.31.1 language server version) with a potential fix. So please try it and let us know if it solves this issue. |
We plan to make some changes as part of hashicorp/terraform-ls#1056 to help us understand situations like this (performance). While CPU/memory profiles can already be collected, these would not be as useful without context (such as some understanding of the workspace - no of files, folders, sizes of files etc.). In the meantime, the only suggestion I can make is to avoid opening large/deep workspaces with lots of folders, esp. monorepos - i.e. open the one or few individual folders that you actually need to edit at any given time. This may not be most convenient, but should help avoid most performance issues for now. Thank you for your patience and understanding. |
I find that if I run a I don't know if allowing Here are logs that occur when I attempt to exclude
|
Same here. I have a folder structure in a repository with hundreds of If, the same repository has not done |
Is there going to be a fix for the terraform-ls high cpu issue? |
Just switched to VS Code today. Two different plugins caused such high CPU that my Mac began losing charge and eventually ran out of battery while plugged in. This was one of them. I haven't modified any terraform files since switching: I've just pointed VS at my existing code root and after I installed this plugin, I saw the terraform-ls go nuts. |
I had this issue as well. Turning off the reference count setting like @smiller171 mentioned lowered CPU usage significantly (from 600% to around 150%), but using 150% CPU while my Terraform workspaces are sitting idle still seems excessive. |
Today, I did the following:
I would love it if someone else tried this and reported their results. |
@jgspratt Did steps 2-4 and observed same behaviour as described in step 6. |
We know this has been a frustrating experience and appreciate your understanding while we gathered feedback and examples to diagnose this issue. We've created #1557 as a central place to see updates on what we are doing to address performance issues in terraform-ls in both the short and long term and pinned it to the repo. We'll be adding more detail there as we implement fixes. As we work on this we'll be recording the content and then closing the individual issues so that everyone has one place to look at instead of searching for individual tickets for updates. |
We've released With the fix, we should be back to terraform-ls If you have the time, please give it a try and let us know how it works for you. Please open a new issue rather than replying here, as this issue has gotten so many replies with different experiences it is hard to process. I am going to close this as we're using #1557 as a central tracking issue, so subscribe to that to see continued updates. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Versions
Extension
VS Code
But I upgraded from 1.71.x to 1.74.3 to try to fix the issue but it didn't help.
Operating System
Terraform Version
Steps To Reproduce
Steps to reproduce the behavior:
htop
I can see the extension bombarding my cpu withterraform-ls serve
processes.Expected Behavior
Saves and formats file in milliseconds.
Actual Behavior
Never formats or saves and noticably slows down pc a lot.
Additional context
This started happening throughout the day. It might have to do with specific code but I cannot share.
I tried:
but none of those had an effect.
For now I've had to disable the extension entirely and use another one since it is so debilitating to the system's performance.
The text was updated successfully, but these errors were encountered: