hashicorp / terraform-plugin-mux

A router for Terraform's RPC protocol.
Mozilla Public License 2.0
34 stars 11 forks source link

Remove Extraneous Caching of Resource Schemas #168

Closed bflad closed 1 year ago

bflad commented 1 year ago

terraform-plugin-mux version

v0.10.0

Relevant provider source code

N/A

Terraform Configuration Files

N/A

Expected Behavior

terraform-plugin-mux should not cache resource schemas unless there is a really good reason as it inflates peak memory usage for providers. Currently all resource schemas are cached, which is problematic with larger providers (either in resource count and/or schema size). We are exploring whether Terraform itself can limit the amount of resource schema data being requested from providers to reduce overall memory utilization on both sides of the protocol. The resource schema caching in this Go module hinders any efforts in that regard though.

Actual Behavior

terraform-plugin-mux caches all resource schemas when creating a mux server. This caching is currently used with:

The pre-loaded GetProviderSchema response is unnecessary and can likely be wholly deferred until after server startup and the actual RPC is called. The mux server already has a separate, small cache map for duplicate checking and raising implementation error diagnostics. There may be additional protocol changes necessary if the protocol implements "limited" GetProviderSchema RPC requests though.

For the PlanResourceChange cache usage:

Steps to Reproduce

  1. terraform validate / terraform plan / terraform apply

References

github-actions[bot] commented 2 months ago

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.