Describe the bug
interpreter.MatchesRegexOptimization compiles a matches() pattern once, at plan time. As of cel-go v0.30.0 that stops happening for programs built by protovalidate: the generic stdlib matches overload runs instead, so every evaluation recompiles the pattern.
To Reproduce
Check which components this affects:
Sample expression and input that reproduces the issue:
^[a-z][a-z0-9_]{1,62}[a-z0-9]$
Test setup here https://github.com/miparnisari/celgo-repro:
go test ./... # passes on v0.29.2, fails on v0.30.0
and
$ sh run.sh
=== cel-go v0.29.2 ===
OneRule 406.1 ns/op 96 B/op 5 allocs/op
ThreeRules 1213 ns/op 289 B/op 15 allocs/op
Nested 2579 ns/op 592 B/op 30 allocs/op
regexp.compile: 515kB (4.56% of allocated bytes)
callers of String.Match / MatchString:
515kB 100% | github.com/google/cel-go/interpreter.init.func4 (inline)
0 0% 0% 515kB 4.56% | regexp.Compile
515kB 100% | regexp.compile
=== cel-go v0.30.0 ===
OneRule 23113 ns/op 45251 B/op 241 allocs/op
ThreeRules 81346 ns/op 132748 B/op 1449 allocs/op
Nested 155523 ns/op 266863 B/op 2899 allocs/op
regexp.compile: 1985.39MB (95.34% of allocated bytes)
callers of String.Match / MatchString:
1984.89MB 100% | regexp.MatchString (inline)
0.50MB 0.025% | regexp.MustCompile (inline)
0 0% 0% 1985.39MB 95.34% | regexp.Compile
1985.39MB 100% | regexp.compile
2062.47MB 100% | github.com/google/cel-go/common/types.String.Match
0 0% 0% 2062.47MB 99.04% | regexp.MatchString
1984.89MB 96.24% | regexp.Compile (inline)
77.58MB 3.76% | regexp.(*Regexp).MatchString (inline)
Expected behavior
No regression in performance in v0.30.0
Additional context
N/A
Describe the bug
interpreter.MatchesRegexOptimizationcompiles amatches()pattern once, at plan time. As of cel-go v0.30.0 that stops happening for programs built by protovalidate: the generic stdlibmatchesoverload runs instead, so every evaluation recompiles the pattern.To Reproduce
Check which components this affects:
Sample expression and input that reproduces the issue:
Test setup here https://github.com/miparnisari/celgo-repro:
and
Expected behavior
No regression in performance in v0.30.0
Additional context
N/A