Le 19/08/2021 à 15:43, yla...@apache.org a écrit :
Author: ylavic
Date: Thu Aug 19 13:43:23 2021
New Revision: 1892450

URL: http://svn.apache.org/viewvc?rev=1892450&view=rev
Log:
core: don't break out iovec coalescing for metadata in ap_core_output_filter().

* server/core_filters.c (send_brigade_nonblocking):
   Keep filling in the iovec when the next bucket has no ->length.

Modified:
     httpd/httpd/trunk/server/core_filters.c

Modified: httpd/httpd/trunk/server/core_filters.c
URL: 
http://svn.apache.org/viewvc/httpd/httpd/trunk/server/core_filters.c?rev=1892450&r1=1892449&r2=1892450&view=diff
==============================================================================
--- httpd/httpd/trunk/server/core_filters.c (original)
+++ httpd/httpd/trunk/server/core_filters.c Thu Aug 19 13:43:23 2021
@@ -604,7 +604,7 @@ static apr_status_t send_brigade_nonbloc
           */
          if (nbytes > sconf->flush_max_threshold
                  && next != APR_BRIGADE_SENTINEL(bb)
-                && !is_in_memory_bucket(next)) {
+                && next->length && !is_in_memory_bucket(next)) {
              (void)apr_socket_opt_set(s, APR_TCP_NOPUSH, 1);
              rv = writev_nonblocking(s, bb, ctx, nbytes, nvec, c);
              if (rv != APR_SUCCESS) {




Hi,

The comment above this code is:
        /* Flush above max threshold, unless the brigade still contains in
         * memory buckets which we want to try writing in the same pass (if
         * we are at the end of the brigade, the write will happen outside
         * the loop anyway).
         */

With the added next->length, IIUC, we will *also* process the bucket *after* the metadata. So we could accumulate above flush_max_threshold for no good reason (i.e. not processing data already in memory).

Is it what is expected?


Maybe we should:
  - remove the continue around line 728      AND
- the whole block between "/* Make sure that these new data fit in our iovec. */" and "nvec++;" be inside a "if (bucket->length)"


This way, when above the limit, we would check if the bucket is metadata or already in memory, one by one.


Something like: (with svn diff -x -w to skip whitespace changes)


Index: server/core_filters.c
===================================================================
--- server/core_filters.c       (révision 1909955)
+++ server/core_filters.c       (copie de travail)
@@ -719,10 +719,9 @@
             if (!nvec) {
                 apr_bucket_delete(bucket);
             }
-            continue;
         }
-
         /* Make sure that these new data fit in our iovec. */
+        else {
         if (nvec == ctx->nvec) {
             if (nvec == NVEC_MAX) {
                 sock_nopush(s, 1);
@@ -754,6 +753,7 @@
         ctx->vec[nvec].iov_base = (void *)data;
         ctx->vec[nvec].iov_len = length;
         nvec++;
+        }

         /* Flush above max threshold, unless the brigade still contains in
* memory buckets which we want to try writing in the same pass (if


CJ

Reply via email to