Subject: Re: loaning for read() of regular files
To: Alan Barrett <apb@cequrux.com>
From: Chuck Silvers <chuq@chuq.com>
List: tech-kern
Date: 02/16/2005 06:57:08
On Wed, Feb 16, 2005 at 10:40:04AM +0200, Alan Barrett wrote:
> On Tue, 15 Feb 2005, Chuck Silvers wrote:
> > I've been fiddling with some changes that implement loaning pages for read()
> > of regular files for quite a while, and I figure it's time to share them.
> 
> Is this likely to help rsync's horrible disk-hogging
> performance?  See the map_file() and map_ptr() functions in
> pkgsrc/net/rsync/work/rsync-2.6.3/fileio.c, where they give
> some excuse for using read rather than mmap.

the comment there is:

/* This provides functionality somewhat similar to mmap() but using read().
 * It gives sliding window access to a file.  mmap() is not used because of
 * the possibility of another program (such as a mailer) truncating the
 * file thus giving us a SIGBUS. */

so they were just being a bit lazy.


the changes I propose will not change rsync's disk-access behaviour at all,
but if rsync manages to read() into the same memory buffer multiple times
without modifying the memory in between, the loaned pages will avoid some
memory-to-memory copies and thus use less CPU time.  I would hope that that
would happen quite frequently, but map_ptr() has this code to copy data
within the buffer that read() filled in sometimes, and I don't know how
often that case is triggered.

-Chuck