mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-20 20:50:44 +00:00
OPTIM/MINOR: move struct sockaddr_storage to the tail of structs
Struct sockaddr_storage is huge (128 bytes) and severely impacts the cache. It also displaces other struct members, causing them to have larger relative offsets. By moving these few occurrences to the end of the structs which host them, we can reduce the code size by no less than 2 kB !
This commit is contained in:
parent
37229df9c1
commit
7b81563443
@ -101,7 +101,6 @@ struct listener {
|
|||||||
int state; /* state: NEW, INIT, ASSIGNED, LISTEN, READY, FULL */
|
int state; /* state: NEW, INIT, ASSIGNED, LISTEN, READY, FULL */
|
||||||
int options; /* socket options : LI_O_* */
|
int options; /* socket options : LI_O_* */
|
||||||
struct licounters *counters; /* statistics counters */
|
struct licounters *counters; /* statistics counters */
|
||||||
struct sockaddr_storage addr; /* the address we listen to */
|
|
||||||
struct protocol *proto; /* protocol this listener belongs to */
|
struct protocol *proto; /* protocol this listener belongs to */
|
||||||
int nbconn; /* current number of connections on this listener */
|
int nbconn; /* current number of connections on this listener */
|
||||||
int maxconn; /* maximum connections allowed on this listener */
|
int maxconn; /* maximum connections allowed on this listener */
|
||||||
@ -126,6 +125,8 @@ struct listener {
|
|||||||
char *interface; /* interface name or NULL */
|
char *interface; /* interface name or NULL */
|
||||||
int maxseg; /* for TCP, advertised MSS */
|
int maxseg; /* for TCP, advertised MSS */
|
||||||
|
|
||||||
|
/* warning: this struct is huge, keep it at the bottom */
|
||||||
|
struct sockaddr_storage addr; /* the address we listen to */
|
||||||
struct {
|
struct {
|
||||||
const char *file; /* file where the section appears */
|
const char *file; /* file where the section appears */
|
||||||
int line; /* line where the section appears */
|
int line; /* line where the section appears */
|
||||||
|
@ -191,7 +191,6 @@ struct proxy {
|
|||||||
unsigned int fe_req_ana, be_req_ana; /* bitmap of common request protocol analysers for the frontend and backend */
|
unsigned int fe_req_ana, be_req_ana; /* bitmap of common request protocol analysers for the frontend and backend */
|
||||||
unsigned int fe_rsp_ana, be_rsp_ana; /* bitmap of common response protocol analysers for the frontend and backend */
|
unsigned int fe_rsp_ana, be_rsp_ana; /* bitmap of common response protocol analysers for the frontend and backend */
|
||||||
int mode; /* mode = PR_MODE_TCP, PR_MODE_HTTP or PR_MODE_HEALTH */
|
int mode; /* mode = PR_MODE_TCP, PR_MODE_HTTP or PR_MODE_HEALTH */
|
||||||
struct sockaddr_storage dispatch_addr; /* the default address to connect to */
|
|
||||||
union {
|
union {
|
||||||
struct proxy *be; /* default backend, or NULL if none set */
|
struct proxy *be; /* default backend, or NULL if none set */
|
||||||
char *name; /* default backend name during config parse */
|
char *name; /* default backend name during config parse */
|
||||||
@ -280,13 +279,6 @@ struct proxy {
|
|||||||
|
|
||||||
int conn_retries; /* maximum number of connect retries */
|
int conn_retries; /* maximum number of connect retries */
|
||||||
int cap; /* supported capabilities (PR_CAP_*) */
|
int cap; /* supported capabilities (PR_CAP_*) */
|
||||||
struct sockaddr_storage source_addr; /* the address to which we want to bind for connect() */
|
|
||||||
#if defined(CONFIG_HAP_CTTPROXY) || defined(CONFIG_HAP_LINUX_TPROXY)
|
|
||||||
struct sockaddr_storage tproxy_addr; /* non-local address we want to bind to for connect() */
|
|
||||||
char *bind_hdr_name; /* bind to this header name if defined */
|
|
||||||
int bind_hdr_len; /* length of the name of the header above */
|
|
||||||
int bind_hdr_occ; /* occurrence number of header above: >0 = from first, <0 = from end, 0=disabled */
|
|
||||||
#endif
|
|
||||||
int iface_len; /* bind interface name length */
|
int iface_len; /* bind interface name length */
|
||||||
char *iface_name; /* bind interface name or NULL */
|
char *iface_name; /* bind interface name or NULL */
|
||||||
int (*accept)(struct session *s); /* application layer's accept() */
|
int (*accept)(struct session *s); /* application layer's accept() */
|
||||||
@ -322,6 +314,16 @@ struct proxy {
|
|||||||
int uuid; /* universally unique proxy ID, used for SNMP */
|
int uuid; /* universally unique proxy ID, used for SNMP */
|
||||||
unsigned int backlog; /* force the frontend's listen backlog */
|
unsigned int backlog; /* force the frontend's listen backlog */
|
||||||
unsigned int bind_proc; /* bitmask of processes using this proxy. 0 = all. */
|
unsigned int bind_proc; /* bitmask of processes using this proxy. 0 = all. */
|
||||||
|
|
||||||
|
/* warning: these structs are huge, keep them at the bottom */
|
||||||
|
struct sockaddr_storage dispatch_addr; /* the default address to connect to */
|
||||||
|
struct sockaddr_storage source_addr; /* the address to which we want to bind for connect() */
|
||||||
|
#if defined(CONFIG_HAP_CTTPROXY) || defined(CONFIG_HAP_LINUX_TPROXY)
|
||||||
|
struct sockaddr_storage tproxy_addr; /* non-local address we want to bind to for connect() */
|
||||||
|
char *bind_hdr_name; /* bind to this header name if defined */
|
||||||
|
int bind_hdr_len; /* length of the name of the header above */
|
||||||
|
int bind_hdr_occ; /* occurrence number of header above: >0 = from first, <0 = from end, 0=disabled */
|
||||||
|
#endif
|
||||||
struct error_snapshot invalid_req, invalid_rep; /* captures of last errors */
|
struct error_snapshot invalid_req, invalid_rep; /* captures of last errors */
|
||||||
|
|
||||||
/* used only during configuration parsing */
|
/* used only during configuration parsing */
|
||||||
|
@ -99,20 +99,13 @@ struct server {
|
|||||||
unsigned maxconn, minconn; /* max # of active sessions (0 = unlimited), min# for dynamic limit. */
|
unsigned maxconn, minconn; /* max # of active sessions (0 = unlimited), min# for dynamic limit. */
|
||||||
int nbpend; /* number of pending connections */
|
int nbpend; /* number of pending connections */
|
||||||
int maxqueue; /* maximum number of pending connections allowed */
|
int maxqueue; /* maximum number of pending connections allowed */
|
||||||
|
struct freq_ctr sess_per_sec; /* sessions per second on this server */
|
||||||
struct srvcounters counters; /* statistics counters */
|
struct srvcounters counters; /* statistics counters */
|
||||||
|
|
||||||
struct list pendconns; /* pending connections */
|
struct list pendconns; /* pending connections */
|
||||||
struct list actconns; /* active connections */
|
struct list actconns; /* active connections */
|
||||||
struct task *check; /* the task associated to the health check processing */
|
struct task *check; /* the task associated to the health check processing */
|
||||||
|
|
||||||
struct sockaddr_storage addr; /* the address to connect to */
|
|
||||||
struct sockaddr_storage source_addr; /* the address to which we want to bind for connect() */
|
|
||||||
#if defined(CONFIG_HAP_CTTPROXY) || defined(CONFIG_HAP_LINUX_TPROXY)
|
|
||||||
struct sockaddr_storage tproxy_addr; /* non-local address we want to bind to for connect() */
|
|
||||||
char *bind_hdr_name; /* bind to this header name if defined */
|
|
||||||
int bind_hdr_len; /* length of the name of the header above */
|
|
||||||
int bind_hdr_occ; /* occurrence number of header above: >0 = from first, <0 = from end, 0=disabled */
|
|
||||||
#endif
|
|
||||||
int iface_len; /* bind interface name length */
|
int iface_len; /* bind interface name length */
|
||||||
char *iface_name; /* bind interface name or NULL */
|
char *iface_name; /* bind interface name or NULL */
|
||||||
struct port_range *sport_range; /* optional per-server TCP source ports */
|
struct port_range *sport_range; /* optional per-server TCP source ports */
|
||||||
@ -145,6 +138,15 @@ struct server {
|
|||||||
unsigned lb_nodes_now; /* number of lb_nodes placed in the tree (C-HASH) */
|
unsigned lb_nodes_now; /* number of lb_nodes placed in the tree (C-HASH) */
|
||||||
struct tree_occ *lb_nodes; /* lb_nodes_tot * struct tree_occ */
|
struct tree_occ *lb_nodes; /* lb_nodes_tot * struct tree_occ */
|
||||||
|
|
||||||
|
/* warning, these structs are huge, keep them at the bottom */
|
||||||
|
struct sockaddr_storage addr; /* the address to connect to */
|
||||||
|
struct sockaddr_storage source_addr; /* the address to which we want to bind for connect() */
|
||||||
|
#if defined(CONFIG_HAP_CTTPROXY) || defined(CONFIG_HAP_LINUX_TPROXY)
|
||||||
|
struct sockaddr_storage tproxy_addr; /* non-local address we want to bind to for connect() */
|
||||||
|
char *bind_hdr_name; /* bind to this header name if defined */
|
||||||
|
int bind_hdr_len; /* length of the name of the header above */
|
||||||
|
int bind_hdr_occ; /* occurrence number of header above: >0 = from first, <0 = from end, 0=disabled */
|
||||||
|
#endif
|
||||||
unsigned down_time; /* total time the server was down */
|
unsigned down_time; /* total time the server was down */
|
||||||
time_t last_change; /* last time, when the state was changed */
|
time_t last_change; /* last time, when the state was changed */
|
||||||
struct timeval check_start; /* last health check start time */
|
struct timeval check_start; /* last health check start time */
|
||||||
@ -152,7 +154,6 @@ struct server {
|
|||||||
short check_status, check_code; /* check result, check code */
|
short check_status, check_code; /* check result, check code */
|
||||||
char check_desc[HCHK_DESC_LEN]; /* health check descritpion */
|
char check_desc[HCHK_DESC_LEN]; /* health check descritpion */
|
||||||
|
|
||||||
struct freq_ctr sess_per_sec; /* sessions per second on this server */
|
|
||||||
int puid; /* proxy-unique server ID, used for SNMP */
|
int puid; /* proxy-unique server ID, used for SNMP */
|
||||||
|
|
||||||
char *check_data; /* storage of partial check results */
|
char *check_data; /* storage of partial check results */
|
||||||
|
Loading…
Reference in New Issue
Block a user