]> git.ipfire.org Git - thirdparty/haproxy.git/commit
OPTIM: pattern: only apply LRU cache for large enough lists
authorWilly Tarreau <w@1wt.eu>
Sun, 3 Nov 2024 17:42:26 +0000 (18:42 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 15 Nov 2024 14:33:04 +0000 (15:33 +0100)
commit555994c96889966fa4dac6d9a444f4094778f593
tree2ed17777eb0c4182b9df2afe3fb7dd5c7d4a74d2
parent25b05927456780aaca2d61f6b05b9a4ad4302eb3
OPTIM: pattern: only apply LRU cache for large enough lists

As shown in issue #1518, the LRU cache has a non-null cost that can
sometimes be above the match cost it's trying to avoid. After a number
of tests, it appears that:
  - "simple" match operations (sub, beg, end, int etc) reach a break-even
    after ~20 patterns in list
  - "heavy" match operations (reg) reach a break-even after ~5 patterns in
    list

Let's only consult the LRU cache when the number of patterns in the
expression is at least as large as this limit. Of course there will
always be outliers but it already starts good.

Another improvement consists in reducing the cache size to further
speed up lookups, which makes sense if less expressions use the cache.
src/pattern.c