mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 07:07:04 +02:00
MINOR: build: define DEBUG_STRESS
Define a new build mode DEBUG_STRESS. This will be used to stress some code parts which cannot be reproduce easily with an alternative suboptimal code. First, a global <mode_stress> is set either to 1 or 0 depending on DEBUG_STRESS compilation. A new global keyword "stress-level" is also defined. It allows to specify a level from 0 to 9, to increase the stress incurred on the code. Helper macro STRESS_RUN* are defined for each stress level. This allows to easily specify an instruction in default execution and a stress counterpart if running on the corresponding stress level.
This commit is contained in:
parent
f36ac42274
commit
9d19fc4cf7
2
Makefile
2
Makefile
@ -263,7 +263,7 @@ endif
|
||||
# DEBUG_NO_POOLS, DEBUG_FAIL_ALLOC, DEBUG_STRICT_ACTION=[0-3], DEBUG_HPACK,
|
||||
# DEBUG_AUTH, DEBUG_SPOE, DEBUG_UAF, DEBUG_THREAD, DEBUG_STRICT, DEBUG_DEV,
|
||||
# DEBUG_TASK, DEBUG_MEMORY_POOLS, DEBUG_POOL_TRACING, DEBUG_QPACK, DEBUG_LIST,
|
||||
# DEBUG_GLITCHES.
|
||||
# DEBUG_GLITCHES, DEBUG_STRESS.
|
||||
DEBUG =
|
||||
|
||||
#### Trace options
|
||||
|
@ -3035,6 +3035,13 @@ stats-file <path>
|
||||
values to its internal counters. Use the CLI command "dump stats-file" to
|
||||
produce such stats-file. See the management manual for more details.
|
||||
|
||||
stress-level <level>
|
||||
Activate alternative code to stress haproxy binary. Level is an integer from
|
||||
0 to 9. The default value 0 disable any stressing execution. Levels from 1 to
|
||||
9 will increase the stress pressure on the haproxy binary. Note that using
|
||||
any positive level can significantly hurt performance. As such it should
|
||||
never be activated unless for debugging purpose and on a developer request.
|
||||
|
||||
strict-limits
|
||||
Makes process fail at startup when a setrlimit fails. HAProxy tries to set the
|
||||
best setrlimit according to what has been calculated. If it fails, it will
|
||||
|
22
include/haproxy/stress.h
Normal file
22
include/haproxy/stress.h
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef _HAPROXY_STRESS_H
|
||||
#define _HAPROXY_STRESS_H
|
||||
|
||||
#ifdef DEBUG_STRESS
|
||||
enum { mode_stress = 1 };
|
||||
#else
|
||||
enum { mode_stress = 0 };
|
||||
#endif
|
||||
|
||||
extern int mode_stress_level;
|
||||
|
||||
#define STRESS_RUN1(a,b) (mode_stress && unlikely(mode_stress_level >= 1) ? (a) : (b))
|
||||
#define STRESS_RUN2(a,b) (mode_stress && unlikely(mode_stress_level >= 2) ? (a) : (b))
|
||||
#define STRESS_RUN3(a,b) (mode_stress && unlikely(mode_stress_level >= 3) ? (a) : (b))
|
||||
#define STRESS_RUN4(a,b) (mode_stress && unlikely(mode_stress_level >= 4) ? (a) : (b))
|
||||
#define STRESS_RUN5(a,b) (mode_stress && unlikely(mode_stress_level >= 5) ? (a) : (b))
|
||||
#define STRESS_RUN6(a,b) (mode_stress && unlikely(mode_stress_level >= 6) ? (a) : (b))
|
||||
#define STRESS_RUN7(a,b) (mode_stress && unlikely(mode_stress_level >= 7) ? (a) : (b))
|
||||
#define STRESS_RUN8(a,b) (mode_stress && unlikely(mode_stress_level >= 8) ? (a) : (b))
|
||||
#define STRESS_RUN9(a,b) (mode_stress && unlikely(mode_stress_level >= 9) ? (a) : (b))
|
||||
|
||||
#endif /* _HAPROXY_STRESS_H */
|
@ -24,6 +24,7 @@
|
||||
#include <haproxy/log.h>
|
||||
#include <haproxy/peers.h>
|
||||
#include <haproxy/protocol.h>
|
||||
#include <haproxy/stress.h>
|
||||
#include <haproxy/tools.h>
|
||||
|
||||
int cluster_secret_isset;
|
||||
@ -1642,6 +1643,32 @@ static int cfg_parse_global_localpeer(char **args, int section_type, struct prox
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cfg_parse_global_stress_level(char **args, int section_type, struct proxy *curpx,
|
||||
const struct proxy *defpx, const char *file, int line,
|
||||
char **err)
|
||||
{
|
||||
char *stop;
|
||||
int level;
|
||||
|
||||
if (too_many_args(1, args, err, NULL))
|
||||
return -1;
|
||||
|
||||
if (*(args[1]) == 0) {
|
||||
memprintf(err, "'%s' expects a level as an argument.", args[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
level = strtol(args[1], &stop, 10);
|
||||
if ((*stop != '\0') || level < 0 || level > 9) {
|
||||
memprintf(err, "'%s' level must be between 0 and 9 inclusive.", args[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
mode_stress_level = level;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct cfg_kw_list cfg_kws = {ILH, {
|
||||
{ CFG_GLOBAL, "prealloc-fd", cfg_parse_prealloc_fd },
|
||||
{ CFG_GLOBAL, "force-cfg-parser-pause", cfg_parse_global_parser_pause, KWF_EXPERIMENTAL },
|
||||
@ -1687,6 +1714,7 @@ static struct cfg_kw_list cfg_kws = {ILH, {
|
||||
{ CFG_GLOBAL, "presetenv", cfg_parse_global_env_opts, KWF_DISCOVERY },
|
||||
{ CFG_GLOBAL, "chroot", cfg_parse_global_chroot },
|
||||
{ CFG_GLOBAL, "localpeer", cfg_parse_global_localpeer, KWF_DISCOVERY },
|
||||
{ CFG_GLOBAL, "stress-level", cfg_parse_global_stress_level },
|
||||
{ 0, NULL, NULL },
|
||||
}};
|
||||
|
||||
|
@ -299,6 +299,8 @@ struct build_opts_str {
|
||||
int must_free;
|
||||
};
|
||||
|
||||
int mode_stress_level = 0;
|
||||
|
||||
/*********************************************************************/
|
||||
/* general purpose functions ***************************************/
|
||||
/*********************************************************************/
|
||||
|
Loading…
Reference in New Issue
Block a user