]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MEDIUM: server: server-state global file stored in a tree
authorBaptiste Assmann <bedis9@gmail.com>
Thu, 13 Jun 2019 11:24:29 +0000 (13:24 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 17 Jun 2019 11:40:42 +0000 (13:40 +0200)
commitda29fe2360e61a5ed4acd283765b20addd5a3ea8
tree57ea6f330236ba58346f70cfc16c9edfd3c40c13
parentd4376302377e4f51f43a183c2c91d929b27e1ae3
MEDIUM: server: server-state global file stored in a tree

Server states can be recovered from either a "global" file (all backends)
or a "local" file (per backend).

The way the algorithm to parse the state file was first implemented was good
enough for a low number of backends and servers per backend.
Basically, for each backend the state file (global or local) is opened,
parsed entirely and for each line we check if it contains data related to
a server from the backend we're currently processing.
We must read the file entirely, just in case some lines for the current
backend are stored at the end of the file.
This does not scale at all!

This patch changes the behavior above for the "global" file only. Now,
the global file is read and parsed once and all lines it contains are
stored in a tree, for faster discovery.
This result in way much less fopen, fgets, and strcmp calls, which make
loading of very big state files very quick now.
include/types/server.h
src/server.c