-
Notifications
You must be signed in to change notification settings - Fork 135
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
Lazy-load embedded provider schemas to improve performance #990
Comments
Based on various sources and experimenting it appears that:
In my experiment, I tried to load ~70MiB JSON file with schemas into memdb and then delete it. This resulted in allocation of 198MiB, which dropped back to zero after garbage collection. The garbage collector acted automatically in ~2mins after deletion, but I was also able to force it via Crucially, the memory usage/profile remains the same regardless of whether the file is loaded via Furthermore I can confirm that breaking down the JSON would have positive impact on peak memory usage. When I tried to store just 1 small part of the JSON into memdb from the ~70MiB JSON, the whole JSON had to be parsed and allocated 1st. The memory was later garbage collected, but loading just the necessary data from a smaller JSON means less pressure on the GC, lower peak memory usage and likely also less CPU spent on parsing the JSON data repeatedly. |
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. |
Background
As documented in https://github.com/hashicorp/terraform-ls/blob/main/docs/benchmarks.md#memory-usage we currently load 1 big blob of JSON with all ~200 providers into memory, which makes up the majority of the ~300MB of memory.
terraform-ls/internal/schemas/gen/gen.go
Lines 163 to 180 in 81b49a1
Aside from memory usage, it also impacts the
initialize
response time - i.e. time it takes for the server to become ready for other requests. It currently takes 90+% of the 2 seconds.terraform-ls/internal/langserver/handlers/service.go
Lines 510 to 513 in 4308af8
Related:
terraform providers schema
#645Proposal
There's no exact proposal yet, but there are early ideas we have discussed within the team:
Each area comes with some different trade-offs which may need to be considered alongside the issues referenced above.
The text was updated successfully, but these errors were encountered: