-
Notifications
You must be signed in to change notification settings - Fork 137
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
Terraform Language Server is Slow and Laggy #487
Comments
Hi @ekristen However I can't conclusively say that what you're experiencing is related to that particular issue. Can you provide me any more details to better understand what the problem may be?
|
I also just found a bug that may be related to what you described
|
I'm experiencing the same issue described by OP: formatting on save runs slowly if I don't cancel it, and error squigglies disappear at 1-2 characters per second. Here's the debug information:
The delay appears to be proportional to the number of changes I make at about 1s per change. For example, if I type "1" and save, saving takes ~1s. If I type "12345" and save, then backspace all 5 characters and save again, each save takes ~5s. "1234567890", save, backspace all 10 characters, save, and each save takes ~10s. If I select and delete multiple lines in a single change, saving takes 1s, and undoing it and saving takes 1s. If I type a whole comment, saving takes minutes, but if I select and delete it, it's ~1s. You can see this in the timestamps of the Gist I shared, where there's a message Hopefully this helps. Is there any other information I can provide? |
@btmills Thank you for providing these details. That's a lot of details and they may as well be symptoms of different unrelated problems, so I'll try to pick and respond to those that may seem more "out of ordinary" than others.
This is within the area of expected memory usage at this point, see #506 for little more context. In general the usage is expected to rise with the number of (unique) providers in use throughout the workspace and size of these providers (e.g. number of resources and data sources, or fields within those). Currently schemas are preloaded into memory before we even know whether or not we were able to source the schema locally. If you always Feel free to subscribe to that issue to be notified about updates in that area.
Just to double check - are you absolutely sure this amount of CPU is allocated by The reason I'm asking is because (as evident from the attached log) VS Code will trigger formatting upon save, which after handed over to Were you able to reproduce this with a fresh installation from https://releases.hashicorp.com/terraform/ or any other official source (Homebrew Tap, Linux packages)? If yes can you try disabling formatting in VS Code settings and see if that makes any change in CPU consumption on save? "[terraform]": {
"editor.formatOnSave": false
},
This would suggest that #426 is indeed the root cause - i.e. the server has received multiple requests, but only processes a single one at a time in a blocking fashion. I do have a draft PR here #489 - I just need to read up a little bit more on the context of why did we decrease the concurrency and what exact problems we experienced in the past when concurrency was higher. Also I want to see if #504 can be implemented in the same PR to give users a little more control over this. |
#506 is interesting, thanks! 150-250MB isn't causing any memory pressure right now, but I do
Just double checked to confirm. This time, I typed a one-line comment, so ~60 chars, and did not save the file. Here's Activity Monitor:
I waited for CPU usage to drop back down and the VSCode
With
I just ran In the logs, I see 46 incoming
Am I correct that concurrency was originally decreased in #120 with v0.3.0? Like the OP, because of signing I can't go back and check older versions to see exactly when this started, but I only noticed this ~10 days ago, so the v0.16.0 release seems like a likely candidate. I was definitely not experiencing this more than two weeks ago, so I suspect that this didn't occur in v0.15.0. I'm wondering if something else changed recently that caused caused serial requests to become an issue a couple weeks ago after having been fine by themselves for several releases. |
There is another issue to be yet resolved to address another potential source of CPU spikes: With that in mind I'm going to close this issue, but please do let us know if you experience any similar issue in the future via new issue. Attaching CPU profiles to such issues (where high CPU is a symptom) would also be incredibly helpful and would likely help understand the problem and fix it in a timely manner. |
Unfortunately this is no where fixed for me. How do I tell vscode to run with the CPU profiles for the language server since vscode installs and runs it? Those instructions seem to be missing from the troubleshooting guide? I honestly think it's worse than before. I'm running on a Macbook Pro 2019 64GB of RAM and when I write a lot of terraform code, I end up waiting MINUTES unless I kill the language server and/or the formatter to get it to save :/ |
That last patch I mentioned (for #509 ) was not released yet - we plan to release it this week though.
You can find some relevant docs on how to change settings of the extension, including how the LS is launched here https://github.com/hashicorp/vscode-terraform/wiki/Manually-Setting-the-Terraform-Executable-Path |
I've adjusted my path, but the log files have remained at 0 bytes all day long. |
@ekristen The CPU profile is written upon shutdown, i.e. when you close VS Code and that instructs the LS to shut down and write the CPU profile to disk. |
I have just shipped VS Code should show prompt automatically within the next 24 hours or upon launch. |
After working in our Terraform configuration a bunch today, I'm happy to report that I didn't notice any of the slowness I was seeing before. Thanks for fixing it! |
That is great to know, thanks for confirming! I'm going to close this issue now but please let us know by opening a new issue and collecting the CPU profile, as mentioned. |
It definitely seems to be way better. Thank you! |
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. |
Not sure what's going on but ever since I upgrade to the latest version, the language server has been extremely lagging and slow.
It's keeping files from being saved during formatting, when it detects errors I can see the red underline disappear character by character after it's been fixed. It's completely unusable.
Unfortunately since you haven't gone back and resigned the older versions after the GPG issue I can't figure out when this started to occur.
The text was updated successfully, but these errors were encountered: