MINOR: config: implement global setting tune.buffers.reserve

Used in conjunction with the dynamic buffer allocator.

tune.buffers.reserve <number>
  Sets the number of buffers which are pre-allocated and reserved for use only
  during memory shortage conditions resulting in failed memory allocations. The
  minimum value is 2 and is also the default. There is no reason a user would
  want to change this value, it's mostly aimed at haproxy core developers.
This commit is contained in:
Willy Tarreau 2014-12-23 22:40:40 +01:00
parent a24adf0795
commit 1058ae73f1
2 changed files with 16 additions and 0 deletions

View File

@ -891,6 +891,12 @@ spread-checks <0..50, in percent>
and +/- 50%. A value between 2 and 5 seems to show good results. The and +/- 50%. A value between 2 and 5 seems to show good results. The
default value remains at 0. default value remains at 0.
tune.buffers.reserve <number>
Sets the number of buffers which are pre-allocated and reserved for use only
during memory shortage conditions resulting in failed memory allocations. The
minimum value is 2 and is also the default. There is no reason a user would
want to change this value, it's mostly aimed at haproxy core developers.
tune.bufsize <number> tune.bufsize <number>
Sets the buffer size to this size (in bytes). Lower values allow more Sets the buffer size to this size (in bytes). Lower values allow more
sessions to coexist in the same amount of RAM, and higher values allow some sessions to coexist in the same amount of RAM, and higher values allow some

View File

@ -696,6 +696,16 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
} }
} }
#endif #endif
else if (!strcmp(args[0], "tune.buffers.reserve")) {
if (*(args[1]) == 0) {
Alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]);
err_code |= ERR_ALERT | ERR_FATAL;
goto out;
}
global.tune.reserved_bufs = atol(args[1]);
if (global.tune.reserved_bufs < 2)
global.tune.reserved_bufs = 2;
}
else if (!strcmp(args[0], "tune.bufsize")) { else if (!strcmp(args[0], "tune.bufsize")) {
if (*(args[1]) == 0) { if (*(args[1]) == 0) {
Alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]); Alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]);