MINOR: mux-pt: Add global option to enable/disable zero-copy forwarding

tune.pt.zero-copy-forwarding parameter can now be used to enable or disable
the zero-copy fast-forwarding for the PT mux only. It is enabled ('on') by
default. It can be disabled by setting the parameter to 'off'. In this case,
this disables receive and send side.
This commit is contained in:
Christopher Faulet 2023-12-04 14:48:52 +01:00
parent 7732323cf3
commit eccef69137
2 changed files with 46 additions and 0 deletions

View File

@ -1211,6 +1211,7 @@ The following keywords are supported in the "global" section :
- tune.pipesize
- tune.pool-high-fd-ratio
- tune.pool-low-fd-ratio
- tune.pt.zero-copy-forwarding
- tune.quic.frontend.conn-tx-buffers.limit
- tune.quic.frontend.max-idle-timeout
- tune.quic.frontend.max-streams-bidi
@ -2921,6 +2922,8 @@ tune.disable-zero-copy-forwarding
Thanks to this directive, it is possible to disable this optimization. Note
it also disable any kernel tcp splicing.
See also: tune.pt.zero-copy-forwarding
tune.events.max-events-at-once <number>
Sets the number of events that may be processed at once by an asynchronous
task handler (from event_hdl API). <number> should be included between 1
@ -3347,6 +3350,14 @@ tune.pool-low-fd-ratio <number>
use before we stop putting connection into the idle pool for reuse. The
default is 20.
tune.pt.zero-copy-forwarding { on | off }
Enables ('on') of disabled ('off') the zero-copy forwarding of data for the
pass-through multiplexer. To be used, the kernel splicing must also be
configured. It is enabled by default.
See also: tune.disable-zero-copy-forwarding, option splice-auto,
option splice-request and option splice-response
tune.quic.frontend.conn-tx-buffers.limit <number>
This settings defines the maximum number of buffers allocated for a QUIC
connection on data emission. By default, it is set to 30. QUIC buffers are

View File

@ -12,6 +12,7 @@
#include <haproxy/api.h>
#include <haproxy/buf.h>
#include <haproxy/cfgparse.h>
#include <haproxy/connection.h>
#include <haproxy/pipe.h>
#include <haproxy/stconn.h>
@ -654,6 +655,11 @@ static int mux_pt_fastfwd(struct stconn *sc, unsigned int count, unsigned int fl
TRACE_ENTER(PT_EV_RX_DATA, conn, sc, 0, (size_t[]){count});
if (global.tune.no_zero_copy_fwd & NO_ZERO_COPY_FWD_PT) {
se_fl_clr(ctx->sd, SE_FL_MAY_FASTFWD);
goto end;
}
se_fl_clr(ctx->sd, SE_FL_RCV_MORE | SE_FL_WANT_ROOM);
conn->flags &= ~CO_FL_WAIT_ROOM;
sdo = mux_pt_opposite_sd(ctx);
@ -810,6 +816,35 @@ static int mux_pt_sctl(struct stconn *sc, enum mux_sctl_type mux_sctl, void *out
}
}
/* config parser for global "tune.pt.zero-copy-forwarding" */
static int cfg_parse_pt_zero_copy_fwd(char **args, int section_type, struct proxy *curpx,
const struct proxy *defpx, const char *file, int line,
char **err)
{
if (too_many_args(1, args, err, NULL))
return -1;
if (strcmp(args[1], "on") == 0)
global.tune.no_zero_copy_fwd &= ~NO_ZERO_COPY_FWD_PT;
else if (strcmp(args[1], "off") == 0)
global.tune.no_zero_copy_fwd |= NO_ZERO_COPY_FWD_PT;
else {
memprintf(err, "'%s' expects 'on' or 'off'.", args[0]);
return -1;
}
return 0;
}
/* config keyword parsers */
static struct cfg_kw_list cfg_kws = {ILH, {
{ CFG_GLOBAL, "tune.pt.zero-copy-forwarding", cfg_parse_pt_zero_copy_fwd },
{ 0, NULL, NULL }
}};
INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws);
/* The mux operations */
const struct mux_ops mux_tcp_ops = {
.init = mux_pt_init,