]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[OPTIM] small optimization on session_process_counters()
authorWilly Tarreau <w@1wt.eu>
Mon, 26 Nov 2007 19:15:35 +0000 (20:15 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 26 Nov 2007 19:22:47 +0000 (20:22 +0100)
It was possible to slightly reduce the size and the number of
operations in session_process_counters(). Two 64 bit comparisons
were removed, reducing the code by 98 bytes on x86 due to the lack
of registers. The net observed performance gain is almost 2%, which
cannot be attributed to those optimizations, but more likely to
induced changes in code alignment in other functions.

src/session.c

index e7fd8bd762783f444db8a5e8124351d8d1c40b15..594f7df1fa3d17e85a9599cb0c3832f29d18ff4b 100644 (file)
@@ -102,36 +102,36 @@ int init_session()
        return pool2_session != NULL;
 }
 
-void session_process_counters(struct session *s) {
-
+void session_process_counters(struct session *s)
+{
        unsigned long long bytes;
 
-       if (s->req && s->req->total != s->logs.bytes_in) {
+       if (s->req) {
                bytes = s->req->total - s->logs.bytes_in;
+               s->logs.bytes_in = s->req->total;
+               if (bytes) {
+                       s->fe->bytes_in          += bytes;
 
-               s->fe->bytes_in         += bytes;
-
-               if (s->be != s->fe)
-                       s->be->bytes_in += bytes;
-
-               if (s->srv)
-                       s->srv->bytes_in += bytes;
+                       if (s->be != s->fe)
+                               s->be->bytes_in  += bytes;
 
-               s->logs.bytes_in = s->req->total;
+                       if (s->srv)
+                               s->srv->bytes_in += bytes;
+               }
        }
 
-       if (s->rep && s->rep->total != s->logs.bytes_out) {
+       if (s->rep) {
                bytes = s->rep->total - s->logs.bytes_out;
+               s->logs.bytes_out = s->rep->total;
+               if (bytes) {
+                       s->fe->bytes_out          += bytes;
 
-               s->fe->bytes_out        += bytes;
-
-               if (s->be != s->fe)
-                       s->be->bytes_out += bytes;
-
-               if (s->srv)
-                       s->srv->bytes_out += bytes;
+                       if (s->be != s->fe)
+                               s->be->bytes_out  += bytes;
 
-               s->logs.bytes_out = s->rep->total;
+                       if (s->srv)
+                               s->srv->bytes_out += bytes;
+               }
        }
 }