Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to compile regex constants at program creation time #497

Merged
merged 3 commits into from
Mar 1, 2022

Conversation

jpbetz
Copy link
Collaborator

@jpbetz jpbetz commented Feb 26, 2022

This provides a program option to inject an optimization (by way of a Interpretable factory) for any regex function.

A matches optimization is provided and enabled when OptOptimize is set.

unoptimized matches:

BenchmarkInterpreter/matches
BenchmarkInterpreter/matches-8  165296	      7135 ns/op	    5845 B/op	

optimized matches:

BenchmarkInterpreter/matches
BenchmarkInterpreter/matches-8  898917	      1413 ns/op	     210 B/op	

@jpbetz
Copy link
Collaborator Author

jpbetz commented Feb 26, 2022

cc @TristonianJones @liggitt

@jpbetz
Copy link
Collaborator Author

jpbetz commented Feb 26, 2022

@TristonianJones I wasn't sure what API changes were best here. I'm open to suggestions alternatives to the RegexPatternArg functions.Override field and the CompiledRegexStringConst interface.

Possible alternatives would be to have RegexPatternArg accept an enumeration of options instead of an *int (the regex pattern is always the 1st argument in all the usages I'm aware of).

Possible alternatives to CompiledRegexStringConst would be a trait.

@jpbetz jpbetz force-pushed the regex-pre-compile branch 2 times, most recently from 79677b1 to 230c5df Compare February 26, 2022 04:01
interpreter/functions/functions.go Outdated Show resolved Hide resolved
interpreter/decorators.go Outdated Show resolved Hide resolved
@jpbetz jpbetz force-pushed the regex-pre-compile branch 2 times, most recently from ce28037 to cabcdb8 Compare February 28, 2022 23:50
cel/cel_test.go Outdated Show resolved Hide resolved
@jpbetz jpbetz force-pushed the regex-pre-compile branch 2 times, most recently from a4abdcd to e1f31a1 Compare March 1, 2022 20:15
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.

2 participants