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
{{ message }}
Repository navigation
Template expressions are compiled on every evaluation #8136
expressions.EvaluateTemplate compiles each expression on every call (json_templates.go#L284), and compiling rebuilds expr's builtin function table each time. Evaluation itself is a small share of the cost.
Callers that pass no expr options evaluate the same few templates repeatedly:
Caller
Runs
RunningPromotionsByArgoCDApplications, app name and namespace templates (indexer.go#L280, #L294)
Every add/update of a Running Promotion in the informer cache
Measured (main @ e778d67, BenchmarkEvaluateTemplate from the fix PR, no options)
Template
ns/op
B/op
allocs/op
main (no expression)
12
16
1
${{ vars.imageRepo }}
4,345
10,922
93
Three expressions in one string
12,271
30,838
218
Proposed change
Cache compiled programs, keyed by expression, for calls without options. Calls with options keep compiling: a program holds the functions it was compiled with (program.go#L28), and callers such as the Promotion evaluator pass functions bound to one Promotion's context.
Activity