]> git.kaiwu.me - haproxy.git/commit
MINOR: sample: add new sample fetch functions reporting current CPU usage
authorWilly Tarreau <w@1wt.eu>
Tue, 14 Apr 2026 15:42:36 +0000 (17:42 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 14 Apr 2026 15:47:18 +0000 (17:47 +0200)
commit90e8ccd9c2a09d8b64a4a1a5fadb435768d96b2a
tree4ea888bdf69f7c083999bdefd4e30f9cb50d1c15
parent630ef96f92f1bd5586effc9126ca3b56872303fe
MINOR: sample: add new sample fetch functions reporting current CPU usage

Some features can automatically turn on or off depending on CPU usage,
but it's not easy to measure it. Let's provide 3 new sample fetch functions
reporting the CPU usage as measured inside haproxy during the previous
polling loop, and reported in "idle" stats header / "show info", or used
by tune.glitches.kill.cpu-usage, or maxcompcpuusage:

  - cpu_usage_thr: CPU usage between 0 and 100 of the current thread, used
    by functions above
  - cpu_usage_grp: CPU usage between 0 and 100, averaged over all threads of
    the same group as the current one.
  - cpu_usage_proc: CPU usage between 0 and 100, averaged over all threads
    of the current process

Note that the value will fluctuate since it only covers a few tens to
hundreds of requests of the last polling loop, but it reports what is
being used to take decisions.

It could also be used to disable some non-essential debugging/processing
under too high loads for example.
doc/configuration.txt
src/sample.c