]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stream: don't prune variables if the list is empty
authorWilly Tarreau <w@1wt.eu>
Sun, 28 Oct 2018 12:44:36 +0000 (13:44 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 28 Oct 2018 12:46:47 +0000 (13:46 +0100)
The vars_prune() and vars_init() functions involve locking while most of
the time there is no variable at all in streams nor sessions. Let's check
for emptiness before calling these functions. Simply doing this has
increased the multithreaded performance from 1.5 to 5% depending on the
workload.

src/proto_http.c
src/stream.c

index 48cb383a0dae5ea7565bce3b427f961f0c915d5f..39900deac17e57da620d3801bdf32dd7bb16e202 100644 (file)
@@ -7566,8 +7566,10 @@ void http_end_txn(struct stream *s)
                memset(s->res_cap, 0, fe->nb_rsp_cap * sizeof(void *));
        }
 
-       vars_prune(&s->vars_txn, s->sess, s);
-       vars_prune(&s->vars_reqres, s->sess, s);
+       if (!LIST_ISEMPTY(&s->vars_txn.head))
+               vars_prune(&s->vars_txn, s->sess, s);
+       if (!LIST_ISEMPTY(&s->vars_reqres.head))
+               vars_prune(&s->vars_reqres, s->sess, s);
 }
 
 /* to be used at the end of a transaction to prepare a new one */
index ad1ccbee408b1a24c534b843a8a8acb6a05049a2..d27dae3a225f45a61ef216a45553cd628a2499c0 100644 (file)
@@ -376,8 +376,10 @@ static void stream_free(struct stream *s)
        }
 
        /* Cleanup all variable contexts. */
-       vars_prune(&s->vars_txn, s->sess, s);
-       vars_prune(&s->vars_reqres, s->sess, s);
+       if (!LIST_ISEMPTY(&s->vars_txn.head))
+               vars_prune(&s->vars_txn, s->sess, s);
+       if (!LIST_ISEMPTY(&s->vars_reqres.head))
+               vars_prune(&s->vars_reqres, s->sess, s);
 
        stream_store_counters(s);
 
@@ -2258,8 +2260,10 @@ redo:
 
                /* prune the request variables and swap to the response variables. */
                if (s->vars_reqres.scope != SCOPE_RES) {
-                       vars_prune(&s->vars_reqres, s->sess, s);
-                       vars_init(&s->vars_reqres, SCOPE_RES);
+                       if (!LIST_ISEMPTY(&s->vars_reqres.head)) {
+                               vars_prune(&s->vars_reqres, s->sess, s);
+                               vars_init(&s->vars_reqres, SCOPE_RES);
+                       }
                }
 
                do {