You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
we spend CPU to parse shared.tf twice and also store both the AST (*hcl.File) and any diagnostics ([]*hcl.Diagnostic) twice (i.e. it ends up taking twice as much space in memory).
Proposal
Update the parser package to ensure that it looks up the AST & diagnostics for existing file - i.e. does a lookup in memdb and saves the same pointers to the map/slice.
One unfortunate edge case (effectively a race condition) which needs addressing is that the link destination (module which contains the regular file which has links pointing to it from elsewhere) may not be parsed yet at the time that the link itself is being parsed.
We can try to decouple file walking logic from the terraform/parser package to
walk files in a directory before scheduling jobs to discover any links
ensure that modules are walked in the right order
Implementation Notes
Here's a simple test which can test whether two symlinked files are are sharing the same pointer:
Context
As pointed out initially in #1398 the language server currently handles symlinks in way that is far from ideal from resource consumption perspective.
For example, given two modules which have files linked between them
we spend CPU to parse
shared.tf
twice and also store both the AST (*hcl.File
) and any diagnostics ([]*hcl.Diagnostic
) twice (i.e. it ends up taking twice as much space in memory).Proposal
Update the
parser
package to ensure that it looks up the AST & diagnostics for existing file - i.e. does a lookup in memdb and saves the same pointers to the map/slice.One unfortunate edge case (effectively a race condition) which needs addressing is that the link destination (module which contains the regular file which has links pointing to it from elsewhere) may not be parsed yet at the time that the link itself is being parsed.
We can try to decouple file walking logic from the
terraform/parser
package toImplementation Notes
Here's a simple test which can test whether two symlinked files are are sharing the same pointer:
The text was updated successfully, but these errors were encountered: