Providers of Large Size: Import is very slow in Python #3753
Labels
bug
Something isn't working
new
Un-triaged issue
pre-built providers
Issues around pre-built providers managed at https://github.com/hashicorp/cdktf-repository-manager
Expected Behavior
When using Python, the time taken for a synth is only correlated to the volume of resources within a stack.
Actual Behavior
When using Python, running any operations with larger providers takes a long time due to lengthy module import load times. You could have a single resource and it would still take ~30s to even get started with the synth.
Steps to Reproduce
Versions
Running with the latest versions
Providers
No response
Gist
No response
Possible Solutions
This is really just a general issue for all providers, but only becomes a big problem for the large ones like AWS. Looking through the issues, this is related to #2792, which was ostensibly fixed by #3030.
Perhaps this is a regression due to some newer behavior in upstream packages but importing AWS is back to taking around 30 seconds and has been for quite a while. I've switched a few projects from python to typescript to get away from it but really it would be nice to not have to do that.
From what I can tell, the bulk of the time is spent loading the very large gzipped assembly in
_jsii
.The root of the module loads it:
/init.py
And worth noting that resource modules also load it:
/foo/init.py
I know much of this is really just behavior of other libraries, and thus this might not be something you can control here. I also realize this is something you have probably already considered, but there is no discussion about it in issues I could find. Is it possible to instruct the package generation to build separate assemblies for each of the submodules of a provider package?
And you would then remove
from ._jsii import *
from the root. And resources would just import their specific jsii assembly.Workarounds
None that are feasible
Anything Else?
No response
References
azurerm
provider: Python package cdktf-cdktf-provider-azurerm extremely slow to import #2792Help Wanted
Community Note
The text was updated successfully, but these errors were encountered: