You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by mi...@apache.org on 2008/11/16 23:23:26 UTC
svn commit: r718125 - in /httpd/httpd/trunk: CHANGES
modules/filters/mod_buffer.c
Author: minfrin
Date: Sun Nov 16 14:23:25 2008
New Revision: 718125
URL: http://svn.apache.org/viewvc?rev=718125&view=rev
Log:
mod_buffer: Optimise the buffering of heap buckets when the heap
buckets stay exactly APR_BUCKET_BUFF_SIZE long.
Modified:
httpd/httpd/trunk/CHANGES
httpd/httpd/trunk/modules/filters/mod_buffer.c
Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=718125&r1=718124&r2=718125&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Sun Nov 16 14:23:25 2008
@@ -2,6 +2,10 @@
Changes with Apache 2.3.0
[ When backported to 2.2.x, remove entry from this file ]
+ *) mod_buffer: Optimise the buffering of heap buckets when the heap
+ buckets stay exactly APR_BUCKET_BUFF_SIZE long. [Graham Leggett,
+ Ruediger Pluem]
+
*) mod_buffer: Optional support for buffering of the input and output
filter stacks. Can collapse many small buckets into fewer larger
buckets, and prevents excessively small chunks being sent over
Modified: httpd/httpd/trunk/modules/filters/mod_buffer.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/filters/mod_buffer.c?rev=718125&r1=718124&r2=718125&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/filters/mod_buffer.c (original)
+++ httpd/httpd/trunk/modules/filters/mod_buffer.c Sun Nov 16 14:23:25 2008
@@ -57,6 +57,7 @@
request_rec *r = f->r;
buffer_ctx *ctx = f->ctx;
apr_status_t rv = APR_SUCCESS;
+ int move = 0;
/* first time in? create a context */
if (!ctx) {
@@ -81,6 +82,11 @@
return ap_pass_brigade(f->next, bb);
}
+ /* Empty buffer means we can potentially optimise below */
+ if (APR_BRIGADE_EMPTY(ctx->bb)) {
+ move = 1;
+ }
+
while (APR_SUCCESS == rv && !APR_BRIGADE_EMPTY(bb)) {
const char *data;
apr_off_t len;
@@ -146,10 +152,26 @@
*/
if (APR_SUCCESS == (rv = apr_bucket_read(e, &data, &size,
APR_BLOCK_READ))) {
- apr_brigade_write(ctx->bb, NULL, NULL, data, size);
+
+ /* further optimisation: if the buckets are already heap
+ * buckets, and the buckets stay exactly APR_BUCKET_BUFF_SIZE
+ * long (as they would be if we were reading bits of a
+ * large bucket), then move the buckets instead of copying
+ * them.
+ */
+ if (move && APR_BUCKET_IS_HEAP(e)) {
+ APR_BUCKET_REMOVE(e);
+ APR_BRIGADE_INSERT_TAIL(ctx->bb, e);
+ if (APR_BUCKET_BUFF_SIZE != size) {
+ move = 0;
+ }
+ } else {
+ apr_brigade_write(ctx->bb, NULL, NULL, data, size);
+ apr_bucket_delete(e);
+ }
+
}
- apr_bucket_delete(e);
}
return rv;