Repository navigation
feat(expression): evaluation budget (max steps, max interval length) - #563
Open
WePlus-Particle wants to merge 3 commits into
Open
WePlus-Particle wants to merge 3 commits into
WePlus-Particle wants to merge 3 commits into
Conversation
New EXPRESSION_CONFIG in zen-expression, re-exported by zen-engine, with two global limits that default to 0 (no limit, the historical behaviour): - max_steps: VM instructions executed by one evaluation; loops run a few instructions per element, so this bounds the time and the memory a map/filter/... can take; - max_interval_length: elements an interval [a..b] may be expanded to when it is iterated. Membership tests (x in [a..b]) do not expand the interval and are not affected. When a limit is exceeded the evaluation fails with VMError::BudgetExceeded. Exposed in the Node and uniffi bindings as expressionMaxSteps and expressionMaxIntervalLength. Refs gorules#561
"Failed to evaluate expression: ..." dropped the underlying VM error, so a caller could not tell a budget error (or any other evaluation error) from a malformed expression. The reason is now appended, as the other nodes already do with node_context_message.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part 2 of #561 (expressions); part 1 is #562.
New
EXPRESSION_CONFIGinzen-expression, re-exported byzen-engine, with two global limits that default to0= no limit, so nothing changes for existing users:max_stepsmap,filter,some, …) run a few instructions per element, so this bounds both the time and the memory a loop can takemax_interval_length[a..b]may be expanded to when it is iterated. Membership tests (x in [a..b]) do not expand the interval and are not affectedVMError::BudgetExceeded { budget, limit }("Evaluation budget exceeded: steps over 5000").u64increment per instruction and is skipped entirely whenmax_stepsis 0.VmInterval::len()computes the size of the expansion without allocating, so an oversized interval is rejected before any memory is used.expressionMaxStepsandexpressionMaxIntervalLength(override_config).zen-expression: "Evaluation budget" section;zen-engineREADME points to it.Test:
evaluation_budget_limits_steps_and_intervalsincore/expression/tests/isolate.rscovers no limit, the step limit, the interval limit, andinon an interval staying unaffected. Fullzen-expressionandzen-enginesuites green;zen-nodejsandzen-unifficompile.