]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[OPTIM] counters: move some max numbers to the counters struct
authorWilly Tarreau <w@1wt.eu>
Sun, 4 Oct 2009 21:12:44 +0000 (23:12 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 4 Oct 2009 21:26:19 +0000 (23:26 +0200)
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.

include/proto/proxy.h
include/proto/server.h
include/types/counters.h
include/types/proxy.h
include/types/server.h
src/backend.c
src/dumpstats.c
src/queue.c

index c0ce2a3a173f8b321aea3274dfb976f10c53896f..bab3da7e44decd2c88698e4e31e5f5ca7614c834 100644 (file)
@@ -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 @@ static void inline proxy_inc_fe_ctr(struct listener *l, struct proxy *fe)
                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 @@ static void inline proxy_inc_be_ctr(struct proxy *be)
 {
        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 */
index 43d9216a0a7feb5c6bf6eb2b75eb772ab01c8f66..a1fa6c2f92adb3312fe7857ea820102867140eb5 100644 (file)
@@ -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 @@ static void inline srv_inc_sess_ctr(struct server *s)
 {
        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 */
index 6bb95a0b2baf1d834bdc65aa6c0d9467a54ad48e..6dfef2295852fd27a5526beb152bc04f3fb89e77 100644 (file)
@@ -28,6 +28,10 @@ struct pxcounters {
        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 licounters {
 };
 
 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 */
 
index aac704dfe8beb0cd08bdd5fa247b936d870ae4bf..ac4b4198d0a17df4050996e18d9c252a9664047a 100644 (file)
@@ -197,13 +197,11 @@ struct proxy {
        } 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 @@ struct proxy {
                         *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 @@ struct proxy {
        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 */
index fa01810fa83724c67b9072f3ed4a2b589f6d6a4f..dae1a71a54347bbfa3740d7109b4508b40919e64 100644 (file)
@@ -83,10 +83,12 @@ struct server {
 
        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 @@ struct server {
        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 */
index 56b15d120450bb048f1bb6e5e100d4a691cf7406..ec8320586848f354edd498662506f50855b1536e 100644 (file)
@@ -856,8 +856,8 @@ int connect_server(struct session *s)
        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);
        }
index f43ab169c75d0117b0f3c42c3e326bdd59053c6d..1317cc080d2941c85c8db09231ada73b30c5c60c 100644 (file)
@@ -1084,7 +1084,7 @@ int stats_dump_proxy(struct session *s, struct proxy *px, struct uri_auth *uri)
                                     "<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 @@ int stats_dump_proxy(struct session *s, struct proxy *px, struct uri_auth *uri)
                                     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 @@ int stats_dump_proxy(struct session *s, struct proxy *px, struct uri_auth *uri)
                                     "",
                                     (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 @@ int stats_dump_proxy(struct session *s, struct proxy *px, struct uri_auth *uri)
                                     "%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 @@ int stats_dump_proxy(struct session *s, struct proxy *px, struct uri_auth *uri)
                                /* 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 @@ int stats_dump_proxy(struct session *s, struct proxy *px, struct uri_auth *uri)
                                     /* 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 @@ int stats_dump_proxy(struct session *s, struct proxy *px, struct uri_auth *uri)
                                     ",,,"
                                     "\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 @@ int stats_dump_proxy(struct session *s, struct proxy *px, struct uri_auth *uri)
                                     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;
index fe940436433b8a888e8e3646f4ea139f9d023287..5be6cdfe9cc7f84c0f42ad84e14ad878cf2dfed2 100644 (file)
@@ -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 @@ struct pendconn *pendconn_add(struct session *sess)
                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;