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

Super-slow, character-by-character diagnostics since 0.29.3 #1317

Closed
1 task
wzyboy opened this issue Jun 23, 2023 · 13 comments
Closed
1 task

Super-slow, character-by-character diagnostics since 0.29.3 #1317

wzyboy opened this issue Jun 23, 2023 · 13 comments
Labels
bug Something isn't working performance Gotta go fast

Comments

@wzyboy
Copy link

wzyboy commented Jun 23, 2023

Language Server Version

0.31.3 (actually anything >= 0.29.3)

Terraform Version

1.2.9

Client Version

Neovim 0.9.1

Terraform Configuration

resource "aws_s3_bucket_lifecycle_configuration" "foo" {}

Steps to Reproduce

  1. Open editor
  2. Type something
  3. Watch the diagnostics appear slowly (see screen record below)
248203620-12e2ed5c-eb6f-4020-b654-b09f8641d03c.mp4

The clip was recorded with this minimal init.vim config:

call plug#begin('~/.vim/plugged')
Plug 'neovim/nvim-lspconfig'
call plug#end()

lua <<EOF
  require'lspconfig'.terraformls.setup{}
EOF

Expected Behavior

The diagnostics appear smoothly.

Actual Behavior

The diagnostics appear slowly.

Gist

https://gist.github.com/wzyboy/248e70eb2d6a6f105354b7adca07ee32

Workarounds

I tried downgrading terraform-ls to earlier versions. With some bisecting, the last known good version is 0.29.2. Since 0.29.3, the slowness starts.

References

Help Wanted

  • I'm interested in contributing a fix myself

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
@wzyboy wzyboy added the bug Something isn't working label Jun 23, 2023
@radeksimko radeksimko added the performance Gotta go fast label Jun 23, 2023
@bcspragu
Copy link

I'm also experiencing this behavior (same as #487) on the latest release. Like @wzyboy, running 0.29.2 solves the problem for me. I'm using Helix as an editor.

Happy to provide LSP logs if that's useful.

@rlees85
Copy link

rlees85 commented Aug 8, 2023

Same problem on neovim. Its been like it for a long while now if not forever.

  • Normally its varying degrees of painfully slow, on a good day its painfully slow and on a bad day you can make a cup of tea in the time it takes to process the fact you wrote a sentence.
  • Very occasionally, the problem does not occur at all and the LSP works amazingly.

I also find that typing suggestions only work occasionally, normally its when the LSP isn't behaving slow. Not sure if its related or not. The LSP is 100% started when typing suggestions don't work as its running really slow and diagnostics are 'working'.

Until now I've just put up with it but I don't know if this is a problem with Neovim or this LSP although I do use ~10 other language servers for varying things and this is the only one that is barely usable - the others work great.

If theres anything I can do ie logs to help then please let me know. I also have to pipe neovim lsp logs to /dev/null due to the amount of noise created by the Terraform LS which is probably another issue...

@jpogran
Copy link
Contributor

jpogran commented Aug 18, 2023

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 hashicorp/vscode-terraform#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.

@bcspragu
Copy link

bcspragu commented Aug 18, 2023

Thanks for the update, and I'm happy to test out the opt-in performance profiling when it's ready, or just recompile terraform-ls and gather pprof profiles, if that's useful.

Though for this particular issue, I don't think it's a question of people's workflows or the size of their projects or anything architectural, I think it's just a regular ole bug. Like "something blocking the main thread and doing redundant network requests" or similar. As @rlees85 wrote, this is "make a cup of tea" slow even on fairly run-of-the-mill Terraform projects. Plus, empirically the issue doesn't exist in 0.29.2, and the delta to 0.29.3 contains a finite number of changes, one of which introduces this pathology.

Beyond this specific bug, I think something as straightforward as debounce ("don't run this analysis until Xms since the last keystroke") or cancelling existing analysis when new strokes come in could be a "quick" fix here, though I've never written an LSP and have no sense of what the best practices are here.

@wzyboy
Copy link
Author

wzyboy commented Aug 18, 2023

I only pinpointed the bug to be introduced between 0.29.2 and 0.29.3, but as @bcspragu pointed out, there are only 43 commits between the two releases.

I'm not familar with Golang, but someone with Golang expertise can use git bisect to find the exact commit that introduced the bug with only a few re-compilations of the Golang code.

It's not a performance improvement that is needed, it's a bug fix.

@rlees85
Copy link

rlees85 commented Aug 20, 2023

I only pinpointed the bug to be introduced between 0.29.2 and 0.29.3, but as @bcspragu pointed out, there are only 43 commits between the two releases.

I'm not familar with Golang, but someone with Golang expertise can use git bisect to find the exact commit that introduced the bug with only a few re-compilations of the Golang code.

It's not a performance improvement that is needed, it's a bug fix.

your not wrong... I'm not a go expert really but I know enough to compile terraform-ls from source. Finding free time is awkward but i'll do it if no-one beats me to it. I can confirm 0.29.2 also fixes the problem for me though which is strange as I thought the problem has been ongoing for ages.

@dbanck
Copy link
Member

dbanck commented Sep 4, 2023

We've just released 0.31.5 which contains two fixes (#1369, #1372) to address this issue.

With the fix, we should be back to 0.29.2 levels of CPU usage while maintaining the memory improvements of 0.29.3.

If you have the time, please give it a try and let us know how it works for you.

@bcspragu
Copy link

bcspragu commented Sep 4, 2023

Happy to give this a test run, but it looks like no release since v0.30.1 contains compiled release artifacts.

Thanks for your work on this!

@dbanck
Copy link
Member

dbanck commented Sep 5, 2023

We changed the release process after 0.30.1, which makes uploading artifacts a little more difficult.
All artifacts have always been and will continue to be available from our release site: https://releases.hashicorp.com

You can find and download the artifacts for 0.31.5 here: https://releases.hashicorp.com/terraform-ls/0.31.5/

Thanks for trying it out!

@bcspragu
Copy link

bcspragu commented Sep 5, 2023

Ah yes, apologies for not RTFM. I'm running 0.31.5 and in preliminary testing, it's been super speedy, even on the ancient hardware (spinning disk, decade old servers) I'm running. I'll keep testing and poking and prodding it, but I think the issue might be fixed!

Looking at your linked fixes, I'm guessing that everyone in this thread is using non-VS Code (which may have different LSP behavior) editors and HDD storage (slow reads from disk). Thanks again for sorting this out!

@wzyboy
Copy link
Author

wzyboy commented Sep 5, 2023

I tried 0.31.5 release and I can confirm that the super-slow issue has been resolved! Thank you for the bug fix!

@wzyboy wzyboy closed this as completed Sep 5, 2023
@rlees85
Copy link

rlees85 commented Sep 7, 2023

Didn't need to write Terraform for a while but yes all god - thanks very much!!

@github-actions
Copy link

github-actions bot commented Oct 8, 2023

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.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working performance Gotta go fast
Projects
None yet
Development

No branches or pull requests

6 participants