]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[OPTIM] do not re-check req buffer when only response has changed
authorWilly Tarreau <w@1wt.eu>
Sun, 8 Mar 2009 18:20:25 +0000 (19:20 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 8 Mar 2009 18:20:25 +0000 (19:20 +0100)
In process_session(), we used to re-run through all the evaluation
loop when only the response had changed. Now we carefully check in
this order :
  - changes to the stream interfaces (only SI_ST_DIS)
  - changes to the request buffer flags
  - changes to the response buffer flags

And we branch to the appropriate section. This saves significant
CPU cycles, which is important since process_session() is one of
the major CPU eaters.

The same changes have been applied to uxst_process_session().

src/proto_uxst.c
src/session.c

index 6351ef109df1f31fa6a50067a3c2f490c24fd078..8891149526daa31c97aaada5be2e724b93960316 100644 (file)
@@ -770,6 +770,7 @@ struct task *uxst_process_session(struct task *t)
         * at this point.
         */
 
+ resync_request:
        /**** Process layer 7 below ****/
 
        resync = 0;
@@ -855,9 +856,14 @@ struct task *uxst_process_session(struct task *t)
        s->req->flags &= BF_CLEAR_READ & BF_CLEAR_WRITE & BF_CLEAR_TIMEOUT;
 
        /* according to benchmarks, it makes sense to resync now */
-       if (resync)
+       if (s->req->prod->state == SI_ST_DIS)
                goto resync_stream_interface;
 
+       if (resync)
+               goto resync_request;
+
+ resync_response:
+       resync = 0;
 
        /* Analyse response */
        if (unlikely(s->rep->flags & BF_HIJACK)) {
@@ -935,9 +941,15 @@ struct task *uxst_process_session(struct task *t)
 
        s->rep->flags &= BF_CLEAR_READ & BF_CLEAR_WRITE & BF_CLEAR_TIMEOUT;
 
-       if (resync)
+       if (s->req->prod->state == SI_ST_DIS)
                goto resync_stream_interface;
 
+       if (s->req->flags != rqf_last)
+               goto resync_request;
+
+       if (resync)
+               goto resync_response;
+
        if (likely(s->rep->cons->state != SI_ST_CLO)) {
                if (s->rep->cons->state == SI_ST_EST)
                        stream_sock_data_finish(s->rep->cons);
index 34ed663a6fd8d6109c2bec3670a6f401f7818742..aa29591cbe7ed6967710931a9568527ded63fb0f 100644 (file)
@@ -714,6 +714,7 @@ resync_stream_interface:
         * at this point.
         */
 
+ resync_request:
        /**** Process layer 7 below ****/
 
        resync = 0;
@@ -855,9 +856,14 @@ resync_stream_interface:
        s->req->flags &= BF_CLEAR_READ & BF_CLEAR_WRITE & BF_CLEAR_TIMEOUT;
 
        /* according to benchmarks, it makes sense to resync now */
-       if (resync)
+       if (s->req->prod->state == SI_ST_DIS || s->req->cons->state == SI_ST_DIS)
                goto resync_stream_interface;
 
+       if (resync)
+               goto resync_request;
+
+ resync_response:
+       resync = 0;
 
        /* Analyse response */
 
@@ -948,9 +954,14 @@ resync_stream_interface:
 
        s->rep->flags &= BF_CLEAR_READ & BF_CLEAR_WRITE & BF_CLEAR_TIMEOUT;
 
-       if (resync)
+       if (s->req->prod->state == SI_ST_DIS || s->req->cons->state == SI_ST_DIS)
                goto resync_stream_interface;
 
+       if (s->req->flags != rqf_last)
+               goto resync_request;
+
+       if (resync)
+               goto resync_response;
 
        /* This is needed only when debugging is enabled, to indicate
         * client-side or server-side close. Please note that in the unlikely