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

Extension causes high cpu load #501

Closed
pradipsilwal opened this issue Oct 16, 2020 · 7 comments
Closed

Extension causes high cpu load #501

pradipsilwal opened this issue Oct 16, 2020 · 7 comments

Comments

@pradipsilwal
Copy link

  • Issue Type: Performance
  • Extension Name: terraform
  • Extension Version: 2.2.3
  • OS Version: Windows_NT x64 10.0.19041
  • VSCode version: 1.50.1

⚠️ Make sure to attach this file from your home-directory:
⚠️c:\Users\silwa\AppData\Local\Temp\hashicorp.terraform-unresponsive.cpuprofile.txt

Find more details here: https://github.com/microsoft/vscode/wiki/Explain-extension-causes-high-cpu-load

@kiklop74
Copy link

Same happens to me and reason for this is that upon starting the VS Code extension executes multiple instances of terraform cli trying to obtain information about providers etc. Not sure how to disable this.

@sidewinder12s
Copy link

Also seeing similar behavior, my environment is setup to open a monorepo with probably 100+ tf backends/workspaces. Wondering if it can more nicely start up/iterate through all those.

Or if this setting might help?
https://code.visualstudio.com/api/references/activation-events#onStartupFinished

@snolan-amount
Copy link

I use tfenv to allow for quick switching between terraform versions on a Mac, so different OS but the issue is the same. On opening a folder where there are lots of terraform projects CPU gets very high, then my computer becomes completely unresponsive and then is restarts. It is definitely this extension causing the problem, I can watch the dozens of tfenv and terraform processes running and eventually crashing the computer.
I grabbed a screenshot before the computer crashed but you get the idea. The extension needs to limit the number of concurrent processes that it spawns to run terraform in all the child folders.
Screen Shot 2020-12-17 at 8 13 43 PM

@dominik-lekse
Copy link

With the Terraform extension enabled in a workspace with 50+ Terraform root modules, I also experience the OS becoming unresponsive due to a high CPU load when opening the workspace.

I assume that this is related to the method terraform-ls inspects the root modules. There is an open issue for terraform-ls to cap the auto-loading: hashicorp/terraform-ls#186.

My hope is, that terraform-ls allows to configure a limit for the auto-loading in the future. I still do not understand why terraform-ls tries to auto-load the modules in a so massively parallel manner.

@dominik-lekse
Copy link

dominik-lekse commented Jan 2, 2021

For affected workspaces, I am using the following settings as a bad workaround to prevent starting terraform-ls and thus prevent massive slow down of the system while at least keep the syntax highlighting feature of the extension.

{
	"settings": {
		"terraform.languageServer": {
			"external": true,
			// Configure a non-existing path for terraform-ls to prevent massive slow down of the system for workspaces with lots of Terraform modules
			"pathToBinary": "/Users/lekse/bin/terraform-ls-fake",
			"args": [
				"serve"
			],
			"maxNumberOfProblems": 1,
			"trace.server": "off"
		}
	}
}

@radeksimko
Copy link
Member

Hi folks,
What I believe was the main cause of the CPU spikes should be resolved in 0.7.0 and future LS releases as per hashicorp/terraform-ls#391

With that I'm going to close this issue, but feel free to open a new one if you continue having issues and include the version of the language server and the extension in such new report please.

@ghost
Copy link

ghost commented Mar 27, 2021

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 context necessary to investigate further.

@ghost ghost locked as resolved and limited conversation to collaborators Mar 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants