On Sun, May 21, 2023 at 2:07 PM Christophe JAILLET
<christophe.jail...@wanadoo.fr> wrote:
>
> 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?

Buckets with ->length == 0 don't contain data (in memory or not), as
opposed to ->length == -1 (unknown/on-read data length) for instance.
No special action is needed for empty buckets at the network level,
they just need to be destroyed when consumed (e.g. for EOR buckets to
terminate/cleanup the underlying request), so the loop simply ignores
them until the flush (i.e. writev/sendfile will delete them finally).
So presumably we can't accumulate above flush_max_threshold by not
flushing before empty buckets? More exactly we won't continue to
accumulate once flush_max_threshold is reached, but we might flush
more than that if the last accumulated bucket crosses the threshold
(that's independent from empty buckets though).


Regards;
Yann.

Reply via email to