haproxy/doc/internals
Willy Tarreau 8f09bdce10 MINOR: buffer: add a buffer list type with functions
The buffer ring is problematic in multiple aspects, one of which being
that it is only usable by one entity. With multiplexed protocols, we need
to have shared buffers used by many entities (streams and connection),
and the only way to use the buffer ring model in this case is to have
each entity store its own array, and keep a shared counter on allocated
entries. But even with the default 32 buf and 100 streams per HTTP/2
connection, we're speaking about 32*101*32 bytes = 103424 bytes per H2
connection, just to store up to 32 shared buffers, spread randomly in
these tables. Some users might want to achieve much higher than default
rates over high speed links (e.g. 30-50 MB/s at 100ms), which is 3 to 5
MB storage per connection, hence 180 to 300 buffers. There it starts to
cost a lot, up to 1 MB per connection, just to store buffer indexes.

Instead this patch introduces a variant which we call a buffer list.
That's basically just a free list encoded in an array. Each cell
contains a buffer structure, a next index, and a few flags. The index
could be reduced to 16 bits if needed, in order to make room for a new
struct member. The design permits initializing a whole freelist at once
using memset(0).

The list pointer is stored at a single location (e.g. the connection)
and all users (the streams) will just have indexes referencing their
first and last assigned entries (head and tail). This means that with
a single table we can now have all our buffers shared between multiple
streams, irrelevant to the number of potential streams which would want
to use them. Now the 180 to 300 entries array only costs 7.2 to 12 kB,
or 80 times less.

Two large functions (bl_deinit() & bl_get()) were implemented in buf.c.
A basic doc was added to explain how it works.
2024-10-12 16:29:15 +02:00
..
api MINOR: buffer: add a buffer list type with functions 2024-10-12 16:29:15 +02:00
acl.txt
body-parsing.txt
connect-status.txt
connection-header.txt
connection-scale.txt
fd-migration.txt
hashing.txt
list.fig
list.png
listener-states.fig
listener-states.png
lua_socket.fig
lua_socket.pdf
muxes.fig
muxes.pdf
muxes.png
muxes.svg
mworker.md DOC: internals: add a documentation about the master worker 2024-06-12 14:46:05 +02:00
notes-layers.txt
notes-poll-connect.txt DOC: internal: commit notes about polling states and flags on connect() 2022-11-17 16:49:00 +01:00
notes-pollhup.txt DOC: internal: commit notes about polling states and flags 2022-11-17 16:49:00 +01:00
notes-polling.txt DOC: internal: commit notes about polling states and flags 2022-11-17 16:49:00 +01:00
pattern.dia
pattern.pdf
polling-states.fig
sched.fig
sched.pdf
sched.png
sched.svg
ssl_cert.dia
stats-v2.txt
stconn-close.txt DOC: internal: add a bit of documentation for the stconn closing conditions 2023-05-23 16:18:19 +02:00
stream-sock-states.fig