Skip to content

Fix failing BenchmarkCheck cases - #1576

Merged
TristonianJones merged 2 commits into
cel-expr:masterfrom
stefanvanburen:svanburen/benchmark-json-field-names
Oct 22, 2026
Merged

TristonianJones merged 2 commits into
cel-expr:masterfrom
stefanvanburen:svanburen/benchmark-json-field-names

Conversation

@stefanvanburen

@stefanvanburen stefanvanburen commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

I found these while measuring #1553. CI doesn't run benchmarks, so they went unnoticed. Since #1283, the three cases with jsonFieldNames: true fail with "undefined field 'singleInt32'". Separately, [{'z': 0}].exists(y, .y.z == y.z) fails whenever b.N is above 1, because Check rewrites the parsed AST in place and every iteration after the first checked the rewritten tree. With both commits, all 142 cases pass.

Copying the AST happens inside the timed loop, alongside the printing and comparison the loop already does, so absolute numbers rise slightly.

cel.Env.Check passes its Ast to the checker without copying, so the same applies there: with a variable y.z, checking the parsed [{'z': 1}].exists(y, .y.z == y.z) a second time and calling AstToString gives [{"z": 1}].exists(y, y.z == y.z), which compares the iteration variable with itself. Evaluation of the checked AST is unaffected; I'm happy to file an issue if you want this tracked.

BenchmarkCheck builds its environment the way TestCheck does, but it
ignored testEnv.jsonFieldNames, so the cases that set it reported
undefined fields and failed. It now passes JSONFieldNames to both the
registry and the checker, as TestCheck does.
Check rewrites the parsed AST in place, for example replacing a
qualified select with an identifier, so iterations after the first
checked an already rewritten AST. For `.y.z` the rewrite drops the
leading dot, and the case failed whenever b.N was above 1. Each
iteration now checks a copy of the parsed AST.
@TristonianJones

Copy link
Copy Markdown
Collaborator

/gcbrun

Comment thread checker/checker_test.go
kimjooyoon

This comment was marked as spam.

@TristonianJones
TristonianJones merged commit da49767 into cel-expr:master Oct 22, 2026
8 checks passed
@stefanvanburen
stefanvanburen deleted the svanburen/benchmark-json-field-names branch October 22, 2026 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants