This is the mail archive of the cygwin-developers@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

readv/writev


I've been playing around with readv and writev in the cygwin DLL,
and I've changed the code around so that the read and write system
calls delegate to the readv and writev system calls (rather than
vice versa as the current DLL has it).  This then allows
individual fhandler classes to override readv and writev to use
the win32 scatter/gather IO.  I've done this conversion for the
socket class so far.  There is a default readv/writev
implementation in the fhandler_base class that delegates to the
existing read/write methods (w/ optimizations for simple cases and
non-slow devices).

I'd like to submit a patch for this but I'd like to get some
feedback on a performance issue first.  The current DLL code has a
code path something like:

    cygwin_read
        -> fhandler_base::read
            -> fhandler_base::raw_read
                -> ReadFile

while my version would be (for a disk file):

    cygwin_read
        -> cygwin_readv
            -> fhandler_base::readv
                -> fhandler_base::read
                    -> fhandler_base::raw_read
                        -> ReadFile

which is an overhead of two more function calls.  On top of this,
there is I've factored out a function to check the incoming iovec
structure; this makes for an extra overhead of three extra
function calls, plus constructing a minimal iovec structure in
cygwin_read.

On my m/c, a 900Mhz Pentium III (?), the same test program I was
using for the __stdcall / regparm testing (read 16Mb from
/dev/zero one byte at a time and write to /dev/zero) takes about 3
seconds longer with the readv/writev changes.  That is, ~38.6
seconds rather than ~35.6 seconds.  So, it's measurable but it's a
pretty extreme test.

Does anyone feel this is important?  If so, I can write separate
code paths for both read/write as well as readv/writev, which
would then be no slower than the current DLL code.  The issue then
is a small increase in DLL size along with more duplicate code to
maintain.

Any votes?

// Conrad




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]