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

Optimize regex #16

Closed
Knetic opened this issue Jun 29, 2016 · 1 comment
Closed

Optimize regex #16

Knetic opened this issue Jun 29, 2016 · 1 comment
Assignees
Milestone

Comments

@Knetic
Copy link
Owner

Knetic commented Jun 29, 2016

Right now, regex are compiled upon every evaluation. This can lead to some punishing execution times when dealing with the regex operators.

There are three ways this can be helped:

  • When a regex operator's right-hand value is built entirely out of constants, that regex can be compiled at expression parsing time, rather than evaluation-time.
  • Users can give a precompiled regex directly to parameters. Instead of type-checking for only Strings, we can also look for *regexp.Regexp, preferring it if present.
  • When a regex operator compiles a regex for a given parameter, an internal cache can be made which maps the parameter's name and value to the compiled regex. This means that if a parameter doesn't change, its regex will (in effect) be statically compiled, similar to the above.

No guarantees about which of these will be implemented. All are subject to testing and benchmarking.

@Knetic Knetic self-assigned this Jun 29, 2016
@Knetic Knetic modified the milestone: 1.5.0 Jun 29, 2016
@Knetic
Copy link
Owner Author

Knetic commented Jul 1, 2016

Implemented pre-compilation of constant patterns in de9ed3b, and supported passing of *regexp.Regexp objects (into parameters) with a074485.

Ultimately decided against trying to do a cache of parameters used as regex which don't change between runs. It gets ugly, and turns into a bit of a hack where the reward is not worth the gain. Instead, going to defer the finer optimization points of using regex-that-doesn't-change in the docs - as part of #15. Users should compile their own regex and pass it as a parameter if they want to use a parameter as a regex.

@Knetic Knetic closed this as completed Jul 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant