MEDIUM: stick-table: set the track-sc limit at boottime via tune.stick-counters
authorWilly Tarreau <w@1wt.eu>
Fri, 6 Jan 2023 15:09:58 +0000 (16:09 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 6 Jan 2023 17:08:49 +0000 (18:08 +0100)
commit6c0117168e4411e108e93b0861f23a533481e136
tree97aea355efbb15555bbb5116a0c60fb12ca67e97
parent3120284c29f8f4c25458c432c544786657e5db26
MEDIUM: stick-table: set the track-sc limit at boottime via tune.stick-counters

The number of stick-counter entries usable by track-sc rules is currently
set at build time. There is no good value for this since the vast majority
of users don't need any, most need only a few and rare users need more.
Adding more counters for everyone increases memory and CPU usages for no
reason.

This patch moves the per-session and per-stream arrays to a pool of a size
defined at boot time. This way it becomes possible to set the number of
entries at boot time via a new global setting "tune.stick-counters" that
sets the limit for the whole process. When not set, the MAX_SESS_STR_CTR
value still applies, or 3 if not set, as before.

It is also possible to lower the value to 0 to save a bit of memory if
not used at all.

Note that a few low-level sample-fetch functions had to be protected due
to the ability to use sample-fetches in the global section to set some
variables.
13 files changed:
doc/configuration.txt
include/haproxy/global-t.h
include/haproxy/session-t.h
include/haproxy/session.h
include/haproxy/stick_table.h
include/haproxy/stream-t.h
include/haproxy/stream.h
src/cfgparse.c
src/haproxy.c
src/session.c
src/stick_table.c
src/stream.c
src/tcp_rules.c