apple / pkl

A configuration as code language with rich validation and tooling.
https://pkl-lang.org
Apache License 2.0
9.84k stars 259 forks source link

Unexpected caching with pkl-go and Evaluator.EvaluateOutputText #500

Closed kallekoo closed 1 month ago

kallekoo commented 1 month ago

Hello!

Using pkl-go v0.6.0, when creating an evaluator like so

var opts = func(o *pkl.EvaluatorOptions) {
    o.AllowedModules = []string{".+"}
    o.AllowedResources = []string{".+"}
    o.CacheDir = ""
}
e, err := pkl.NewEvaluator(ctx, opts)

and evaluating a FileSource like so

s, err := e.EvaluateOutputText(ctx, pkl.FileSource(p))

where the underlying data for the path p changes between evaluations, the evaluator output remains unchanged.

The workaround is to recreate the evaluator at appropriate intervals, but that leads to an overhead when the evaluator is being set up.

holzensp commented 1 month ago

This is expected behaviour. A single evaluator instance caches aggressively. This is how Pkl manages to be deterministic, which is a core design goal.

but that leads to an overhead when the evaluator is being set up

Not caching leads to overhead everywhere else.