Use JIT in regex matching if available

This commit is contained in:
Johan Wikman
2017-03-21 11:03:35 +02:00
parent 17057ef340
commit 117534d288
2 changed files with 19 additions and 1 deletions

View File

@ -102,6 +102,20 @@ bool cache_command_show(const MODULECMD_ARG* pArgs)
return true;
}
int cache_process_init()
{
uint32_t jit_available;
pcre2_config(PCRE2_CONFIG_JIT, &jit_available);
if (!jit_available)
{
MXS_WARNING("pcre2 JIT is not available; regex matching will not be "
"as efficient as it could be.");
}
return 0;
}
}
//
@ -145,7 +159,7 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE()
"A caching filter that is capable of caching and returning cached data.",
VERSION_STRING,
&CacheFilter::s_object,
NULL, /* Process init. */
cache_process_init, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */

View File

@ -532,6 +532,10 @@ static CACHE_RULE *cache_rule_create_regexp(cache_rule_attribute_t attribute,
if (code)
{
// We do not care about the result. If JIT is not present, we have
// complained about it already.
pcre2_jit_compile(code, PCRE2_JIT_COMPLETE);
int n_threads = config_threadcount();
pcre2_match_data **datas = alloc_match_datas(n_threads, code);