mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 14:21:25 +02:00
MINOR: compression: tune.comp.maxlevel
This option allows you to set the maximum compression level usable by the compression algorithm. It affects CPU usage.
This commit is contained in:
parent
0a410e81fb
commit
f3747837e5
@ -465,6 +465,7 @@ The following keywords are supported in the "global" section :
|
|||||||
- spread-checks
|
- spread-checks
|
||||||
- tune.bufsize
|
- tune.bufsize
|
||||||
- tune.chksize
|
- tune.chksize
|
||||||
|
- tune.comp.maxlevel
|
||||||
- tune.http.maxhdr
|
- tune.http.maxhdr
|
||||||
- tune.maxaccept
|
- tune.maxaccept
|
||||||
- tune.maxpollevents
|
- tune.maxpollevents
|
||||||
@ -753,6 +754,12 @@ tune.chksize <number>
|
|||||||
build time. It is not recommended to change this value, but to use better
|
build time. It is not recommended to change this value, but to use better
|
||||||
checks whenever possible.
|
checks whenever possible.
|
||||||
|
|
||||||
|
tune.comp.maxlevel <number>
|
||||||
|
Sets the maximum compression level. The compression level affects CPU
|
||||||
|
usage during compression. This value affects CPU usage during compression.
|
||||||
|
Each session using compression initializes the compression algorithm with
|
||||||
|
this value. The default value is 1.
|
||||||
|
|
||||||
tune.http.maxhdr <number>
|
tune.http.maxhdr <number>
|
||||||
Sets the maximum number of headers in a request. When a request comes with a
|
Sets the maximum number of headers in a request. When a request comes with a
|
||||||
number of headers greater than this value (including the first line), it is
|
number of headers greater than this value (including the first line), it is
|
||||||
|
@ -44,6 +44,7 @@ struct comp_ctx {
|
|||||||
void *zlib_pending_buf;
|
void *zlib_pending_buf;
|
||||||
void *zlib_head;
|
void *zlib_head;
|
||||||
#endif /* USE_ZLIB */
|
#endif /* USE_ZLIB */
|
||||||
|
int cur_lvl;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct comp_algo {
|
struct comp_algo {
|
||||||
|
@ -117,6 +117,7 @@ struct global {
|
|||||||
int zlibmemlevel; /* zlib memlevel */
|
int zlibmemlevel; /* zlib memlevel */
|
||||||
int zlibwindowsize; /* zlib window size */
|
int zlibwindowsize; /* zlib window size */
|
||||||
#endif
|
#endif
|
||||||
|
int comp_maxlevel; /* max HTTP compression level */
|
||||||
} tune;
|
} tune;
|
||||||
struct {
|
struct {
|
||||||
char *prefix; /* path prefix of unix bind socket */
|
char *prefix; /* path prefix of unix bind socket */
|
||||||
|
@ -706,6 +706,22 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
|
|||||||
goto out;
|
goto out;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
else if (!strcmp(args[0], "tune.comp.maxlevel")) {
|
||||||
|
if (*args[1]) {
|
||||||
|
global.tune.comp_maxlevel = atoi(args[1]);
|
||||||
|
if (global.tune.comp_maxlevel < 1 || global.tune.comp_maxlevel > 9) {
|
||||||
|
Alert("parsing [%s:%d] : '%s' expects a numeric value between 1 and 9\n",
|
||||||
|
file, linenum, args[0]);
|
||||||
|
err_code |= ERR_ALERT | ERR_FATAL;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Alert("parsing [%s:%d] : '%s' expects a numeric value between 1 and 9\n",
|
||||||
|
file, linenum, args[0]);
|
||||||
|
err_code |= ERR_ALERT | ERR_FATAL;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (!strcmp(args[0], "uid")) {
|
else if (!strcmp(args[0], "uid")) {
|
||||||
if (global.uid != 0) {
|
if (global.uid != 0) {
|
||||||
Alert("parsing [%s:%d] : user/uid already specified. Continuing.\n", file, linenum);
|
Alert("parsing [%s:%d] : user/uid already specified. Continuing.\n", file, linenum);
|
||||||
|
@ -131,6 +131,7 @@ struct global global = {
|
|||||||
.zlibmemlevel = 8,
|
.zlibmemlevel = 8,
|
||||||
.zlibwindowsize = MAX_WBITS,
|
.zlibwindowsize = MAX_WBITS,
|
||||||
#endif
|
#endif
|
||||||
|
.comp_maxlevel = 1,
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
@ -2088,9 +2088,11 @@ int select_compression_response_header(struct session *s, struct buffer *res)
|
|||||||
ctx.idx = 0;
|
ctx.idx = 0;
|
||||||
|
|
||||||
/* initialize compression */
|
/* initialize compression */
|
||||||
if (s->comp_algo->init(&s->comp_ctx, 1) < 0)
|
if (s->comp_algo->init(&s->comp_ctx, global.tune.comp_maxlevel) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
s->comp_ctx.cur_lvl = global.tune.comp_maxlevel;
|
||||||
|
|
||||||
/* remove Content-Length header */
|
/* remove Content-Length header */
|
||||||
if ((msg->flags & HTTP_MSGF_CNT_LEN) && http_find_header2("Content-Length", 14, res->p, &txn->hdr_idx, &ctx))
|
if ((msg->flags & HTTP_MSGF_CNT_LEN) && http_find_header2("Content-Length", 14, res->p, &txn->hdr_idx, &ctx))
|
||||||
http_remove_header2(msg, &txn->hdr_idx, &ctx);
|
http_remove_header2(msg, &txn->hdr_idx, &ctx);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user