Feature request: Allow an ext code var to be initialized using an ast.Node
- Dominant language
- Go
- Stars
- 1.8k
- Forks
- 263
- PR merge metrics
- No merged PRs in 30d
Description
I have a use-case where a piece of jsonnet code that is costly to eval returns an object and I want to use this object for subsequent invocations of other files in separate VMs as an external code var. This object is big and not everything that is subsequently eval-ed needs to use it.
Each eval runs in an isolated VM partly because of concurrent processing of components and partly because every invocation has a different set of vars which makes the import cache useless anyway. That is, instead of re-using VMs in complex ways taking concurrency into account etc., my code just creates a fresh VM every time.
What would be really helpful is if I could turn the initial object to an `ast.Node` using `SnippetToAST` and initialize it as `vm.ExtCodeNode(name, node)` or something.
Passing in the serialized version of the object negates the gains I've made in the preprocessing in that the extVar is eagerly turned into a node every time even if the component code doesn't happen to require the value of the var. And being a giant object, it happens to be costly to parse.
I hacked together some crappy code to implement `ExtCodeNode` in my local vendor tree and verified that what I'm describing is indeed the bottleneck that makes everything slow.
Other ideas also welcome.
Contributor guide
Assessment
This issue has not been assessed yet.