]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: regex: use a thread-local match pointer for pcre2
authorWilly Tarreau <w@1wt.eu>
Mon, 13 Oct 2025 14:47:50 +0000 (16:47 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 13 Oct 2025 14:56:43 +0000 (16:56 +0200)
commitfda6dc9597ebe8f7ef0bacc3674807195b971813
treef4debdde740d4d293db4fdd272205b83f62e9ad9
parent6f4ca37880757032baee7e6790a1b173f7708b05
MINOR: regex: use a thread-local match pointer for pcre2

The pcre2 matching requires an array of matches for grouping, that is
allocated when executing the rule by pre-processing it, and that is
immediately freed after use. This is quite inefficient and results in
annoying patterns in "show profiling" that attribute the allocations
to libpcre2 and the releases to haproxy.

A good suggestion from Dragan is to pre-allocate these per thread,
since the entry is not specific to a regex. In addition we're already
limited to MAX_MATCH matches so we don't even have the problem of
having to grow it while parsing nor processing.

The current patch adds a per-thread pair of init/deinit functions to
allocate a thread-local entry for that, and gets rid of the dynamic
allocations. It will result in cleaner memory management patterns and
slightly higher performance (+2.5%) when using pcre2.
include/haproxy/regex.h
src/regex.c