]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: pools: compute an estimate of each pool's average needed objects
authorWilly Tarreau <w@1wt.eu>
Fri, 8 May 2020 06:31:56 +0000 (08:31 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 27 May 2020 06:32:42 +0000 (08:32 +0200)
commita1e4f8c27c7677593d747eeef1163af0ee04be74
treec9b9ac6fda1bc9740c6bf0eed37aa1d566bb80b9
parent68ad53cb3781010ccde7c781b6a3a1e926b5ed23
MINOR: pools: compute an estimate of each pool's average needed objects

This adds a sliding estimate of the pools' usage. The goal is to be able
to use this to start to more aggressively free memory instead of keeping
lots of unused objects in pools. The average is calculated as a sliding
average over the last 1024 consecutive measures of ->used during calls to
pool_free(), and is bumped up for 1/4 of its history from ->allocated when
allocation from the pool fails and results in a call to malloc().

The result is a floating value between ->used and ->allocated, that tries
to react fast to under-estimates that result in expensive malloc() but
still maintains itself well in case of stable usage, and progressively
goes down if usage shrinks over time.

This new metric is reported as "needed_avg" in "show pools".

Sadly due to yet another include dependency hell, we couldn't reuse the
functions from freq_ctr.h so they were temporarily duplicated into memory.h.
include/common/memory.h
src/memory.c