Hello!
On Wed, Sep 19, 2012 at 7:18 AM, Lance <lance...@gmail.com> wrote:
> 请问在编译好的openresty中,怎么能看出是否启用了pcre-jit
>
如果在 Linux 上,可以尝试使用我的 Nginx SystemTap 工具箱中的 ngx-pcrejit 脚本对指定的 nginx
worker 进程进行动态追踪:
https://github.com/agentzh/nginx-systemtap-toolkit#ngx-pcrejit
一个例子是:
location ~ '^/re' {
content_by_lua '
ngx.re.match("hello, 1234", "([0-9]+)", "j")
ngx.re.match("hello, 1234", "([0-9]+)")
';
}
假设我的 pcre 安装已经启用了 JIT 支持,但标准 nginx 没有启用 pcre jit 支持,则使用 ngx-pcrejit 追踪
1000 个 GET /re 请求的结果如下:
$ ./ngx-pcrejit -p 31360
Tracing 31360 (/opt/nginx/sbin/nginx)...
Hit Ctrl-C to end.
^C
ngx_http_lua_ngx_re_match: 1000 of 2000 are PCRE JIT'd.
ngx_http_regex_exec: 0 of 1000 are PCRE JIT'd.
这里我只启用了一个 nginx worker 进程,同时它的 pid 是 31360. 值得一提的是,ngx-pcrejit 需要你安装有
pcre 的调试符号(如果你是从源码编译 pcre 的,则需要传递 -g 选项给 C 编译器)。另外,systemtap 似乎对于静态联编到
nginx 中的 pcre 库的支持目前有问题。在我这里(Fedora 17+ SystemTap git master)测试动态联编
libpcre 是没有问题的。
Best regards,
-agentzh