From 2b028dd828cdb5ed88be856115395296634c6fa6 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Tue, 31 Dec 2013 23:56:46 +0100 Subject: [PATCH] OPTIM: session: put unlikely() around the freewheeling code 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 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/session.c b/src/session.c index b2486334d..9712faa3c 100644 --- a/src/session.c +++ b/src/session.c @@ -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.