You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@trafficserver.apache.org by tomr <to...@equalit.ie> on 2016/07/14 06:41:37 UTC

basic regex_map vs map performance

Hi All,

Simple perf question, hopefully easy enough to answer that I don't need to spin up a test environment!

My options are:

 map  http://site.com      http://origin.site.com
 map  http://www.site.com  http://origin.site.com

vs...

 regex_map http://^(www\.)?site\.com$/  http://origin.site.com

We have approx 1000 similar rules. Intuitively I would guess that using 2 map rules each time would be a performance win over using a single regex_map rule. Is that likely to be:
- correct?
- incorrect?
- "it depends" / not that simple and I really should test it?

Thanks in advance,
Tom




Re: basic regex_map vs map performance

Posted by Reindl Harald <h....@thelounge.net>.

Am 14.07.2016 um 19:21 schrieb Leif Hedstrom:
> I believe Bryan and Phil made some performance improvements with PCRE’s, so if your platform has a modern PCRE library, it will be able to use the JIT that it supports.

beware of bugs like https://bugzilla.redhat.com/show_bug.cgi?id=1215701
since then i disable jit for mod_secuirty as example


Re: basic regex_map vs map performance

Posted by Leif Hedstrom <zw...@apache.org>.
> On Jul 14, 2016, at 12:41 AM, tomr <to...@equalit.ie> wrote:
> 
> Hi All,
> 
> Simple perf question, hopefully easy enough to answer that I don't need to spin up a test environment!
> 
> My options are:
> 
> map  http://site.com      http://origin.site.com
> map  http://www.site.com  http://origin.site.com
> 
> vs...
> 
> regex_map http://^(www\.)?site\.com$/  http://origin.site.com
> 
> We have approx 1000 similar rules. Intuitively I would guess that using 2 map rules each time would be a performance win over using a single regex_map rule. Is that likely to be:


Very likely correct. The host lookups are very fast, because of the hash map. But if you only have one regex rule like that, the performance impact is likely so small that it’s worth having that simpler rule just for ease of use and management. The PCRE’s are still pretty fast.

The caveat here is that you have a lot of regexes, you might end up evaluating many of them, so the order of the regexes can have a big impact on performance (i..e put the one most likely to match first in remap.config).

I believe Bryan and Phil made some performance improvements with PCRE’s, so if your platform has a modern PCRE library, it will be able to use the JIT that it supports.

Cheers,

— Leif


> - correct?
> - incorrect?
> - "it depends" / not that simple and I really should test it?
> 
> Thanks in advance,
> Tom
> 
> 
>