mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 15:17:01 +02:00
MINOR: applet: Use an option to disable zero-copy forwarding for all applets
At the beginning of the 3.0-dev cycle, the zero-copy forwarding support was added only for the cache applet with an option to disable it. This was a hack, waiting for a better integration with applets. It is now possible to implement the zero-copy forwarding for any applets. So the specific option for the cache applet was renamed to be used for all applets. And this option is now also checked for the stats applet. Concretely, 'tune.cache.zero-copy-forwarding' was renamed to 'tune.applet.zero-copy-forwarding'.
This commit is contained in:
parent
00152bad85
commit
a9301c96f1
@ -1351,10 +1351,10 @@ The following keywords are supported in the "global" section :
|
||||
- spread-checks
|
||||
- ssl-engine
|
||||
- ssl-mode-async
|
||||
- tune.applet.zero-copy-forwarding
|
||||
- tune.buffers.limit
|
||||
- tune.buffers.reserve
|
||||
- tune.bufsize
|
||||
- tune.cache.zero-copy-forwarding
|
||||
- tune.comp.maxlevel
|
||||
- tune.disable-fast-forward
|
||||
- tune.disable-zero-copy-forwarding
|
||||
@ -3025,6 +3025,12 @@ ssl-mode-async
|
||||
read/write operations (it is only enabled during initial and renegotiation
|
||||
handshakes).
|
||||
|
||||
tune.applet.zero-copy-forwarding { on | off }
|
||||
Enables ('on') of disabled ('off') the zero-copy forwarding of data for the
|
||||
applets. It is enabled by default.
|
||||
|
||||
See also: tune.disable-zero-copy-forwarding.
|
||||
|
||||
tune.buffers.limit <number>
|
||||
Sets a hard limit on the number of buffers which may be allocated per process.
|
||||
The default value is zero which means unlimited. The minimum non-zero value
|
||||
@ -3064,13 +3070,6 @@ tune.bufsize <number>
|
||||
value set using this parameter will automatically be rounded up to the next
|
||||
multiple of 8 on 32-bit machines and 16 on 64-bit machines.
|
||||
|
||||
tune.cache.zero-copy-forwarding { on | off }
|
||||
Enables ('on') of disabled ('off') the zero-copy forwarding of data for the
|
||||
cache applet, when objects are served from the cache to clients. It is
|
||||
enabled by default.
|
||||
|
||||
See also: tune.disable-zero-copy-forwarding.
|
||||
|
||||
tune.comp.maxlevel <number>
|
||||
Sets the maximum compression level. The compression level affects CPU
|
||||
usage during compression. This value affects CPU usage during compression.
|
||||
@ -3094,7 +3093,7 @@ 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.cache.zero-copy-forwarding,
|
||||
See also: tune.pt.zero-copy-forwarding, tune.applet.zero-copy-forwarding,
|
||||
tune.h1.zero-copy-fwd-recv, tune.h1.zero-copy-fwd-send,
|
||||
tune.h2.zero-copy-fwd-send, tune.quic.zero-copy-fwd-send
|
||||
|
||||
|
@ -95,7 +95,7 @@
|
||||
#define NO_ZERO_COPY_FWD_QUIC_SND 0x0080 /* disable zero-copy FF for QUIC on send */
|
||||
#define NO_ZERO_COPY_FWD_FCGI_RCV 0x0100 /* disable zero-copy FF for FCGI on received */
|
||||
#define NO_ZERO_COPY_FWD_FCGI_SND 0x0200 /* disable zero-copy FF for FCGI on send */
|
||||
#define NO_ZERO_COPY_FWD_CACHE 0x0400 /* disable zero-copy FF for cache applet */
|
||||
#define NO_ZERO_COPY_FWD_APPLET 0x0400 /* disable zero-copy FF for applets */
|
||||
|
||||
|
||||
extern int cluster_secret_isset; /* non zero means a cluster secret was initialized */
|
||||
|
29
src/applet.c
29
src/applet.c
@ -15,6 +15,7 @@
|
||||
|
||||
#include <haproxy/api.h>
|
||||
#include <haproxy/applet.h>
|
||||
#include <haproxy/cfgparse.h>
|
||||
#include <haproxy/channel.h>
|
||||
#include <haproxy/htx.h>
|
||||
#include <haproxy/list.h>
|
||||
@ -865,3 +866,31 @@ struct task *task_process_applet(struct task *t, void *context, unsigned int sta
|
||||
TRACE_LEAVE(APPLET_EV_PROCESS, app);
|
||||
return t;
|
||||
}
|
||||
|
||||
/* config parser for global "tune.applet.zero-copy-forwarding" */
|
||||
static int cfg_parse_applet_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_APPLET;
|
||||
else if (strcmp(args[1], "off") == 0)
|
||||
global.tune.no_zero_copy_fwd |= NO_ZERO_COPY_FWD_APPLET;
|
||||
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.applet.zero-copy-forwarding", cfg_parse_applet_zero_copy_fwd },
|
||||
{ 0, NULL, NULL }
|
||||
}};
|
||||
|
||||
INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws);
|
||||
|
30
src/cache.c
30
src/cache.c
@ -1827,7 +1827,7 @@ static void http_cache_io_handler(struct appctx *appctx)
|
||||
if (find_http_meth(istptr(meth), istlen(meth)) == HTTP_METH_HEAD || ctx->send_notmodified)
|
||||
appctx->st0 = HTX_CACHE_EOM;
|
||||
else {
|
||||
if (!(global.tune.no_zero_copy_fwd & (NO_ZERO_COPY_FWD|NO_ZERO_COPY_FWD_CACHE)))
|
||||
if (!(global.tune.no_zero_copy_fwd & (NO_ZERO_COPY_FWD|NO_ZERO_COPY_FWD_APPLET)))
|
||||
se_fl_set(appctx->sedesc, SE_FL_MAY_FASTFWD);
|
||||
|
||||
appctx->to_forward = cache_ptr->body_size;
|
||||
@ -2950,26 +2950,6 @@ parse_cache_flt(char **args, int *cur_arg, struct proxy *px,
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* config parser for global "tune.cache.zero-copy-forwarding" */
|
||||
static int cfg_parse_cache_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_CACHE;
|
||||
else if (strcmp(args[1], "off") == 0)
|
||||
global.tune.no_zero_copy_fwd |= NO_ZERO_COPY_FWD_CACHE;
|
||||
else {
|
||||
memprintf(err, "'%s' expects 'on' or 'off'.", args[0]);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* It reserves a struct show_cache_ctx for the local variables */
|
||||
static int cli_parse_show_cache(char **args, char *payload, struct appctx *appctx, void *private)
|
||||
{
|
||||
@ -3160,14 +3140,6 @@ struct applet http_cache_applet = {
|
||||
.release = http_cache_applet_release,
|
||||
};
|
||||
|
||||
/* config keyword parsers */
|
||||
static struct cfg_kw_list cfg_kws = {ILH, {
|
||||
{ CFG_GLOBAL, "tune.cache.zero-copy-forwarding", cfg_parse_cache_zero_copy_fwd },
|
||||
{ 0, NULL, NULL }
|
||||
}};
|
||||
|
||||
INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws);
|
||||
|
||||
|
||||
/* config parsers for this section */
|
||||
REGISTER_CONFIG_SECTION("cache", cfg_parse_cache, cfg_post_parse_section_cache);
|
||||
|
@ -4539,7 +4539,7 @@ static void http_stats_io_handler(struct appctx *appctx)
|
||||
if (find_http_meth(istptr(meth), istlen(meth)) == HTTP_METH_HEAD)
|
||||
appctx->st0 = STAT_HTTP_DONE;
|
||||
else {
|
||||
if (!(global.tune.no_zero_copy_fwd & NO_ZERO_COPY_FWD))
|
||||
if (!(global.tune.no_zero_copy_fwd & (NO_ZERO_COPY_FWD|NO_ZERO_COPY_FWD_APPLET)))
|
||||
se_fl_set(appctx->sedesc, SE_FL_MAY_FASTFWD);
|
||||
appctx->st0 = STAT_HTTP_DUMP;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user