Re: PCRE with openresty

399 views
Skip to first unread message

agentzh

unread,
May 30, 2012, 5:04:28 AM5/30/12
to Sparsh Gupta, openresty
Hello!

On Wed, May 30, 2012 at 4:51 PM, Sparsh Gupta <spars...@gmail.com> wrote:
> Hello Yichun
>
> Hope you are doing good. I wanted to use pcre_jit on; directive in my
> nginx (openresty) configuration and hence I thought I will compile
> openresty with
>
> --with-pcre=/usr/src/pcre-8.30/ --with-pcre-jit
>
> options. I realized I installed libpcre3-dev library using my
> repository manager and hence was not sure if this is the best way to
> go about this. I depend a lot on regular expressions and hence think
> pcre-jit will help me optimize my configurations
>

Yeah, sure. Your options look good to me :)

And you can specify the "j" regex option when using ngx_lua's ngx.re.*
API to enable this PCRE JIT support. And "j" should always be used
with "o". If the regexes you're using have unlimited variants, then
you should not use either "j" or "o".

The only way to make sure the "j" option for ngx.re.* actually takes
effect is to enable nginx debug logs and check some line like below in
your error.log:

[debug] 5154#0: *2 pcre JIT compiling result: 1

If it is "0" instead of "1" in this line, then PCRE JIT is disabled
for some reason.

Regards,
-agentzh

P.S. I'm cc'ing the openresty mailing list so that other people can
see this too :)

Sparsh Gupta

unread,
May 30, 2012, 5:09:02 AM5/30/12
to agentzh, openresty
Thanks

I tried these configuration options with openresty
(ngx_openresty-1.0.15.7.tar.gz)

./configure --with-luajit --with-http_geoip_module
--with-pcre=/usr/src/pcre-8.30/ --with-pcre-jit

but got an error:
./configure: error: invalid option "--with-pcre-jit"
failed to run command: ./configure --prefix=/usr/local/openresty/nginx \...

when i did ./configure --help I was unable to see --with-pcre-jit as a
valid option

Am I doing something wrong?

Cheers
Sparsh Gupta

agentzh

unread,
May 30, 2012, 5:21:33 AM5/30/12
to Sparsh Gupta, openresty
Hello!

On Wed, May 30, 2012 at 5:09 PM, Sparsh Gupta <spars...@gmail.com> wrote:
> I tried these configuration options with openresty
> (ngx_openresty-1.0.15.7.tar.gz)
>
> ./configure --with-luajit --with-http_geoip_module
> --with-pcre=/usr/src/pcre-8.30/ --with-pcre-jit
>
> but got an error:
> ./configure: error: invalid option "--with-pcre-jit"
> failed to run command: ./configure --prefix=/usr/local/openresty/nginx \...
>
> when i did ./configure --help I was unable to see --with-pcre-jit as a
> valid option
>

The --with-pcre-jit option was first introduced in nginx 1.1.12. The
latest (devel) release of ngx_openresty is based on nginx 1.0.15, so
you do not have this option for ./configure yet.

One option is to compile and install PCRE manually from source and
install it into somewhere like /opt/pcrejit:

cd /usr/src/pcre-8.30/
./configure --prefix=/opt/pcrejit --enable-jit --enable-utf8
make -j2
make install

and then configure ngx_openresty like this:

./configure \
--with-cc-opt="-I/opt/pcrejit/include" \
--with-ld-opt="-L/opt/pcrejit/lib -Wl,-rpath,/opt/pcrejit/lib" \
...

Then the ngx_lua ngx.re.* API can utilize the PCRE JIT support but the
old Nginx core bundled currently does not utilize PCRE JIT yet.

Regards,
-agentzh
Reply all
Reply to author
Forward
0 new messages