]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
OPTIM: session: put unlikely() around the freewheeling code
authorWilly Tarreau <w@1wt.eu>
Tue, 31 Dec 2013 22:56:46 +0000 (23:56 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 31 Dec 2013 22:56:46 +0000 (23:56 +0100)
The code which enables tunnel mode or TCP transfers is rarely used
and at most once per session. Putting it in an unlikely() clause
reduces the length of the hot path of process_session() which is
already quite long, and also slightly reduces its overall size.
Some measurements show a steady gain of about 0.2% thanks to this.

src/session.c

index b2486334d93c635d900f56c72f0fd02d144e7b16..9712faa3ccb1e59a759a06d5b3adb573bb97f755 100644 (file)
@@ -2121,10 +2121,10 @@ struct task *process_session(struct task *t)
         * Note that we're checking CF_SHUTR_NOW as an indication of a possible
         * recent call to channel_abort().
         */
-       if (!s->req->analysers &&
+       if (unlikely(!s->req->analysers &&
            !(s->req->flags & (CF_SHUTW|CF_SHUTR_NOW)) &&
            (s->req->prod->state >= SI_ST_EST) &&
-           (s->req->to_forward != CHN_INFINITE_FORWARD)) {
+           (s->req->to_forward != CHN_INFINITE_FORWARD))) {
                /* This buffer is freewheeling, there's no analyser
                 * attached to it. If any data are left in, we'll permit them to
                 * move.
@@ -2263,10 +2263,10 @@ struct task *process_session(struct task *t)
         * Note that we're checking CF_SHUTR_NOW as an indication of a possible
         * recent call to channel_abort().
         */
-       if (!s->rep->analysers &&
+       if (unlikely(!s->rep->analysers &&
            !(s->rep->flags & (CF_SHUTW|CF_SHUTR_NOW)) &&
            (s->rep->prod->state >= SI_ST_EST) &&
-           (s->rep->to_forward != CHN_INFINITE_FORWARD)) {
+           (s->rep->to_forward != CHN_INFINITE_FORWARD))) {
                /* This buffer is freewheeling, there's no analyser
                 * attached to it. If any data are left in, we'll permit them to
                 * move.