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

vre: Migrate to pcre2 #3635

Merged
merged 1 commit into from Jul 6, 2021
Merged

vre: Migrate to pcre2 #3635

merged 1 commit into from Jul 6, 2021

Conversation

Dridi
Copy link
Member

@Dridi Dridi commented Jun 28, 2021

Now that VRE is the only regular expression API we use, we can migrate its backend to pcre2. The existing 'pcre_*' parameters are also renamed to reflect this migration, and 'pcre_match_limit_recursion' gets special treatment and is renamed to pcre2_depth_limit.

This creates an additional API breakage in VRE: the match_recursion field in struct vre_limits is also renamed. One last breakage is the removal of VRE_has_jit used by only one undocumented varnishtest feature, and the pcre_jit feature is only used by one test case that no longer fails.

The pcre jit compilation feature was broken anyway: sealing it at compile time will not reflect what VRE actually links to. Once we have a test case needing the jit feature, we can introduce a better API for that check.

There is one outstanding performance problem, the ovector that was previously allocated on the stack now needs to be allocated from the heap. It might be possible to implement a pcre2 context to fix that or maybe pool them, but for now we have heap allocations on the critical path. The VRE_sub() function makes sure to make a single ovector allocation (technically a pcre2_match_data allocation) since it's the only one guaranteed to loop on a single regular expression for the regsuball() use case.

Closes #3616
Closes #3559


Only the last commit matters here, the rest comes from #3630.

@Dridi
Copy link
Member Author

Dridi commented Jul 5, 2021

bugwash: OK, but I'll see what was left behind in the documentation before merging.

@Dridi Dridi marked this pull request as ready for review July 5, 2021 15:53
Now that VRE is the only regular expression API we use, we can migrate
its backend to pcre2. The existing 'pcre_*' parameters are also renamed
to reflect this migration, and 'pcre_match_limit_recursion' gets special
treatment and is renamed to pcre2_depth_limit.

This creates an additional API breakage in VRE: the `match_recursion`
field in `struct vre_limits` is also renamed. One last breakage is the
removal of `VRE_has_jit` used by only one undocumented varnishtest
feature, and the pcre_jit feature is only used by one test case that no
longer fails.

The pcre jit compilation feature was broken anyway: sealing it at
compile time will not reflect what VRE actually links to. Once we have
a test case needing the jit feature, we can introduce a better API for
that check.

There is one outstanding performance problem, the ovector that was
previously allocated on the stack now needs to be allocated from the
heap. It might be possible to implement a pcre2 context to fix that or
maybe pool them, but for now we have heap allocations on the critical
path. The VRE_sub() function makes sure to make a single ovector
allocation (technically a pcre2_match_data allocation) since it's the
only one guaranteed to loop on a single regular expression for the
`regsuball()` use case.

On the documentation front, the SmartOS installation instructions are
hidden for lack of a pcre2 package.

Closes varnishcache#3616
Closes varnishcache#3559
@Dridi Dridi merged commit 6014912 into varnishcache:master Jul 6, 2021
@Dridi Dridi deleted the vre2 branch July 6, 2021 17:50
Dridi added a commit to Dridi/oss-fuzz that referenced this pull request Jul 12, 2021
DavidKorczynski pushed a commit to google/oss-fuzz that referenced this pull request Jul 16, 2021
* varnish: Migration to pcre2

See varnishcache/varnish-cache#3635

* varnish: Static linking to pcre2

* varnish: Only build the fuzzer

Static linking of pcre2 fails the libvarnishapi build, not needed by
the ESI fuzzer. That's also less time wasted building irrelevant
components. We can figure out why libvarnishapi fails to build in
this environment later.

* varnish: Missing build step
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move to pcre2
1 participant