MINOR: pattern: add pat_ref_purge_older() to purge old entries
authorWilly Tarreau <w@1wt.eu>
Wed, 28 Oct 2020 17:23:49 +0000 (18:23 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 5 Nov 2020 18:27:09 +0000 (19:27 +0100)
commit94b9abe2009cc5f2f35bee6491e424ba1fcaec61
treee44fcd84b2d28819368024fb05a97d2966ae870e
parent1a6857b9c198ff3f22ae0b3d1d09f419110939d8
MINOR: pattern: add pat_ref_purge_older() to purge old entries

This function will be usable to purge at most a specified number of old
entries from a reference. Entries are declared old if their generation
number is in the past compared to the one passed in argument. This will
ease removal of early entries when new ones have been appended.

We also call malloc_trim() when available, at the end of the series,
because this is one place where there is a lot of memory to save. Reloads
of 1M IP addresses used in an ACL made the process grow up to 1.7 GB RSS
after 10 reloads and roughly stabilize there without this call, versus
only 260 MB when the call is present. Sadly there is no direct equivalent
for jemalloc, which stabilizes around 800MB-1GB.
include/haproxy/pattern.h
src/pattern.c