apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Colm MacCarthaigh <c...@stdlib.net>
Subject [PATCH] Configurable read/write buffer sizes
Date Tue, 06 Sep 2005 20:49:12 GMT

Attached is a patch which makes the read/write buffer size configurable
on a per-file-descriptor basis, ie;

  apr_file_open(&fh, "/dev/zero", APR_WRITE | APR_BUFFERED, 
                APR_UREAD | APR_UWRITE | APR_GREAD, p);

  /* Increase the buffer size to 10k */ 
  apr_file_set_buffer_size(fh, 10240);

  /* Query the buffer size */
  current_bufsize = apr_file_get_buffer_size(filetest);

It supports increasing and decreasing the buffer size, as well as making
an unbuffered file handle buffered, and a buffered file unbuffered.

The patch also adds a new subpool to the file handle, for the buffer
itself, with the subpool being destroyed on buffer resizes.

Other things I'm thinking about;

	Destroying the subpool on apr_file_close, after all the lifetime
	of the buffer should be exactly concurrent with the lifetime of
	the file descriptor.

	Maybe making something like;

		apr_file_set_default_buffer_size(apr_off_t foo); 

	work. 

The implementation in buffer.c should be portable, with the only
changing the file->thlock to file->mutex being neccessary for some of
the other architectures, though I havn't done that porting just yet, I
want to be able to test it on win32 at least first, and maybe get some
feedback :-)

Apart from my immediate problem of needing a buffered stdin, I've done
some extensive benchmarking in the past of the efficiency of various
buffer sizes;

	 http://www.stdlib.net/~colmmacc/Apachecon-EU2005/

See slides 18-21 of the presentation. There are definitely some major
real-world benefits to giving people the ability to tune the buffer
sizes. 

-- 
Colm MacCárthaigh                        Public Key: colm+pgp@stdlib.net

Mime
View raw message