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.
This commit is contained in:
Willy Tarreau 2013-12-31 23:56:46 +01:00
parent 9fe7aae6eb
commit 2b028dd828

View 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.