[OPTIM] counters: move some max numbers to the counters struct
There are a few remaining max values that need to move to counters.
Also, the counters are more often used than some config information,
so get them closer to the other useful struct members for better cache
efficiency.
diff --git a/include/proto/proxy.h b/include/proto/proxy.h
index c0ce2a3..bab3da7 100644
--- a/include/proto/proxy.h
+++ b/include/proto/proxy.h
@@ -1,23 +1,23 @@
/*
- include/proto/proxy.h
- This file defines function prototypes for proxy management.
-
- Copyright (C) 2000-2008 Willy Tarreau - w@1wt.eu
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation, version 2.1
- exclusively.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ * include/proto/proxy.h
+ * This file defines function prototypes for proxy management.
+ *
+ * Copyright (C) 2000-2009 Willy Tarreau - w@1wt.eu
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, version 2.1
+ * exclusively.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
#ifndef _PROTO_PROXY_H
#define _PROTO_PROXY_H
@@ -73,8 +73,8 @@
l->counters->cum_conn++;
update_freq_ctr(&fe->fe_sess_per_sec, 1);
- if (fe->fe_sess_per_sec.curr_ctr > fe->fe_sps_max)
- fe->fe_sps_max = fe->fe_sess_per_sec.curr_ctr;
+ if (fe->fe_sess_per_sec.curr_ctr > fe->counters.fe_sps_max)
+ fe->counters.fe_sps_max = fe->fe_sess_per_sec.curr_ctr;
}
/* increase the number of cumulated connections on the designated backend */
@@ -82,8 +82,8 @@
{
be->counters.cum_beconn++;
update_freq_ctr(&be->be_sess_per_sec, 1);
- if (be->be_sess_per_sec.curr_ctr > be->be_sps_max)
- be->be_sps_max = be->be_sess_per_sec.curr_ctr;
+ if (be->be_sess_per_sec.curr_ctr > be->counters.be_sps_max)
+ be->counters.be_sps_max = be->be_sess_per_sec.curr_ctr;
}
#endif /* _PROTO_PROXY_H */
diff --git a/include/proto/server.h b/include/proto/server.h
index 43d9216..a1fa6c2 100644
--- a/include/proto/server.h
+++ b/include/proto/server.h
@@ -1,23 +1,23 @@
/*
- include/proto/server.h
- This file defines everything related to servers.
-
- Copyright (C) 2000-2009 Willy Tarreau - w@1wt.eu
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation, version 2.1
- exclusively.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ * include/proto/server.h
+ * This file defines everything related to servers.
+ *
+ * Copyright (C) 2000-2009 Willy Tarreau - w@1wt.eu
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, version 2.1
+ * exclusively.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
#ifndef _PROTO_SERVER_H
#define _PROTO_SERVER_H
@@ -40,8 +40,8 @@
{
s->counters.cum_sess++;
update_freq_ctr(&s->sess_per_sec, 1);
- if (s->sess_per_sec.curr_ctr > s->sps_max)
- s->sps_max = s->sess_per_sec.curr_ctr;
+ if (s->sess_per_sec.curr_ctr > s->counters.sps_max)
+ s->counters.sps_max = s->sess_per_sec.curr_ctr;
}
#endif /* _PROTO_SERVER_H */
diff --git a/include/types/counters.h b/include/types/counters.h
index 6bb95a0..6dfef22 100644
--- a/include/types/counters.h
+++ b/include/types/counters.h
@@ -28,6 +28,10 @@
long long cum_feconn, cum_beconn; /* cumulated number of processed sessions */
long long cum_lbconn; /* cumulated number of sessions processed by load balancing */
+ unsigned int fe_sps_max; /* maximum of new sessions per second seen on the frontend */
+ unsigned int be_sps_max; /* maximum of new sessions per second seen on the backend */
+ unsigned int nbpend_max; /* max number of pending connections with no server assigned yet */
+
long long bytes_in; /* number of bytes transferred from the client to the server */
long long bytes_out; /* number of bytes transferred from the server to the client */
@@ -51,6 +55,10 @@
};
struct srvcounters {
+ unsigned int cur_sess_max; /* max number of currently active sessions */
+ unsigned int nbpend_max; /* max number of pending connections reached */
+ unsigned int sps_max; /* maximum of new sessions per second seen on this server */
+
long long cum_sess; /* cumulated number of sessions really sent to this server */
long long cum_lbconn; /* cumulated number of sessions directed by load balancing */
diff --git a/include/types/proxy.h b/include/types/proxy.h
index aac704d..ac4b419 100644
--- a/include/types/proxy.h
+++ b/include/types/proxy.h
@@ -197,13 +197,11 @@
} timeout;
char *id, *desc; /* proxy id (name) and description */
struct list pendconns; /* pending connections with no server assigned yet */
- int nbpend, nbpend_max; /* number of pending connections with no server assigned yet */
+ int nbpend; /* number of pending connections with no server assigned yet */
int totpend; /* total number of pending connections on this instance (for stats) */
unsigned int feconn, beconn; /* # of active frontend and backends sessions */
struct freq_ctr fe_sess_per_sec; /* sessions per second on the frontend */
- unsigned int fe_sps_max; /* maximum of new sessions per second seen on the frontend */
struct freq_ctr be_sess_per_sec; /* sessions per second on the backend */
- unsigned int be_sps_max; /* maximum of new sessions per second seen on the backend */
unsigned int maxconn; /* max # of active sessions on the frontend */
unsigned int fe_sps_lim; /* limit on new sessions per second on the frontend */
unsigned int fullconn; /* #conns on backend above which servers are used at full load */
@@ -244,6 +242,7 @@
*rsp_cap_pool;
struct pool_head *hdr_idx_pool; /* pools of pre-allocated int* used for headers indexing */
char *req_add[MAX_NEWHDR], *rsp_add[MAX_NEWHDR]; /* headers to be added */
+ struct pxcounters counters; /* statistics counters */
int grace; /* grace time after stop request */
char *check_req; /* HTTP or SSL request to use for PR_O_HTTP_CHK|PR_O_SSL3_CHK */
int check_len; /* Length of the HTTP or SSL3 request */
@@ -257,8 +256,6 @@
int no_options; /* PR_O_REDISP, PR_O_TRANSP, ... */
int no_options2; /* PR_O2_* */
- struct pxcounters counters; /* statistics counters */
-
struct {
const char *file; /* file where the section appears */
int line; /* line where the section appears */
diff --git a/include/types/server.h b/include/types/server.h
index fa01810..dae1a71 100644
--- a/include/types/server.h
+++ b/include/types/server.h
@@ -83,10 +83,12 @@
struct proxy *proxy; /* the proxy this server belongs to */
int served; /* # of active sessions currently being served (ie not pending) */
- int cur_sess, cur_sess_max; /* number of currently active sessions (including syn_sent) */
+ int cur_sess; /* number of currently active sessions (including syn_sent) */
unsigned maxconn, minconn; /* max # of active sessions (0 = unlimited), min# for dynamic limit. */
- int nbpend, nbpend_max; /* number of pending connections */
+ int nbpend; /* number of pending connections */
int maxqueue; /* maximum number of pending connections allowed */
+ struct srvcounters counters; /* statistics counters */
+
struct list pendconns; /* pending connections */
struct task *check; /* the task associated to the health check processing */
@@ -127,11 +129,8 @@
short check_status, check_code; /* check result, check code */
struct freq_ctr sess_per_sec; /* sessions per second on this server */
- unsigned int sps_max; /* maximum of new sessions per second seen on this server */
int puid; /* proxy-unique server ID, used for SNMP */
- struct srvcounters counters; /* statistics counters */
-
struct {
const char *file; /* file where the section appears */
int line; /* line where the section appears */
diff --git a/src/backend.c b/src/backend.c
index 56b15d1..ec83205 100644
--- a/src/backend.c
+++ b/src/backend.c
@@ -856,8 +856,8 @@
if (s->srv) {
s->flags |= SN_CURR_SESS;
s->srv->cur_sess++;
- if (s->srv->cur_sess > s->srv->cur_sess_max)
- s->srv->cur_sess_max = s->srv->cur_sess;
+ if (s->srv->cur_sess > s->srv->counters.cur_sess_max)
+ s->srv->counters.cur_sess_max = s->srv->cur_sess;
if (s->be->lbprm.server_take_conn)
s->be->lbprm.server_take_conn(s->srv);
}
diff --git a/src/dumpstats.c b/src/dumpstats.c
index f43ab16..1317cc0 100644
--- a/src/dumpstats.c
+++ b/src/dumpstats.c
@@ -1084,7 +1084,7 @@
"<td align=right>%s</td><td align=right>%s</td>"
"",
U2H0(read_freq_ctr(&px->fe_sess_per_sec)),
- U2H1(px->fe_sps_max), LIM2A2(px->fe_sps_lim, "-"),
+ U2H1(px->counters.fe_sps_max), LIM2A2(px->fe_sps_lim, "-"),
U2H3(px->feconn), U2H4(px->counters.feconn_max), U2H5(px->maxconn),
U2H6(px->counters.cum_feconn), U2H7(px->counters.bytes_in), U2H8(px->counters.bytes_out));
@@ -1138,7 +1138,7 @@
px->state == PR_STIDLE ? "FULL" : "STOP",
relative_pid, px->uuid, STATS_TYPE_FE,
read_freq_ctr(&px->fe_sess_per_sec),
- px->fe_sps_lim, px->fe_sps_max);
+ px->fe_sps_lim, px->counters.fe_sps_max);
}
if (buffer_feed_chunk(rep, &msg) >= 0)
@@ -1301,9 +1301,9 @@
"",
(sv->state & SRV_BACKUP) ? "backup" : "active",
sv_state, sv->id,
- U2H0(sv->nbpend), U2H1(sv->nbpend_max), LIM2A2(sv->maxqueue, "-"),
- U2H3(read_freq_ctr(&sv->sess_per_sec)), U2H4(sv->sps_max),
- U2H5(sv->cur_sess), U2H6(sv->cur_sess_max), LIM2A7(sv->maxconn, "-"),
+ U2H0(sv->nbpend), U2H1(sv->counters.nbpend_max), LIM2A2(sv->maxqueue, "-"),
+ U2H3(read_freq_ctr(&sv->sess_per_sec)), U2H4(sv->counters.sps_max),
+ U2H5(sv->cur_sess), U2H6(sv->counters.cur_sess_max), LIM2A7(sv->maxconn, "-"),
U2H8(sv->counters.cum_sess), U2H9(sv->counters.cum_lbconn));
chunk_printf(&msg,
@@ -1406,8 +1406,8 @@
"%lld,%lld,"
"",
px->id, sv->id,
- sv->nbpend, sv->nbpend_max,
- sv->cur_sess, sv->cur_sess_max, LIM2A0(sv->maxconn, ""), sv->counters.cum_sess,
+ sv->nbpend, sv->counters.nbpend_max,
+ sv->cur_sess, sv->counters.cur_sess_max, LIM2A0(sv->maxconn, ""), sv->counters.cum_sess,
sv->counters.bytes_in, sv->counters.bytes_out,
sv->counters.failed_secu,
sv->counters.failed_conns, sv->counters.failed_resp,
@@ -1469,7 +1469,7 @@
/* rate */
chunk_printf(&msg, "%u,,%u,",
read_freq_ctr(&sv->sess_per_sec),
- sv->sps_max);
+ sv->counters.sps_max);
if (sv->state & SRV_CHECKED) {
/* check_status */
@@ -1514,8 +1514,8 @@
/* sessions rate : current, max, limit */
"<td align=right>%s</td><td align=right>%s</td><td align=right></td>"
"",
- U2H0(px->nbpend) /* or px->totpend ? */, U2H1(px->nbpend_max),
- U2H2(read_freq_ctr(&px->be_sess_per_sec)), U2H3(px->be_sps_max));
+ U2H0(px->nbpend) /* or px->totpend ? */, U2H1(px->counters.nbpend_max),
+ U2H2(read_freq_ctr(&px->be_sess_per_sec)), U2H3(px->counters.be_sps_max));
chunk_printf(&msg,
/* sessions : current, max, limit, total, lbtot */
@@ -1591,7 +1591,7 @@
",,,"
"\n",
px->id,
- px->nbpend /* or px->totpend ? */, px->nbpend_max,
+ px->nbpend /* or px->totpend ? */, px->counters.nbpend_max,
px->beconn, px->counters.beconn_max, px->fullconn, px->counters.cum_beconn,
px->counters.bytes_in, px->counters.bytes_out,
px->counters.denied_req, px->counters.denied_resp,
@@ -1605,7 +1605,7 @@
relative_pid, px->uuid,
px->counters.cum_lbconn, STATS_TYPE_BE,
read_freq_ctr(&px->be_sess_per_sec),
- px->be_sps_max);
+ px->counters.be_sps_max);
}
if (buffer_feed_chunk(rep, &msg) >= 0)
return 0;
diff --git a/src/queue.c b/src/queue.c
index fe94043..5be6cdf 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -1,7 +1,7 @@
/*
* Queue management functions.
*
- * Copyright 2000-2008 Willy Tarreau <w@1wt.eu>
+ * Copyright 2000-2009 Willy Tarreau <w@1wt.eu>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -147,14 +147,14 @@
LIST_ADDQ(&sess->srv->pendconns, &p->list);
sess->srv->nbpend++;
sess->logs.srv_queue_size += sess->srv->nbpend;
- if (sess->srv->nbpend > sess->srv->nbpend_max)
- sess->srv->nbpend_max = sess->srv->nbpend;
+ if (sess->srv->nbpend > sess->srv->counters.nbpend_max)
+ sess->srv->counters.nbpend_max = sess->srv->nbpend;
} else {
LIST_ADDQ(&sess->be->pendconns, &p->list);
sess->be->nbpend++;
sess->logs.prx_queue_size += sess->be->nbpend;
- if (sess->be->nbpend > sess->be->nbpend_max)
- sess->be->nbpend_max = sess->be->nbpend;
+ if (sess->be->nbpend > sess->be->counters.nbpend_max)
+ sess->be->counters.nbpend_max = sess->be->nbpend;
}
sess->be->totpend++;
return p;