Subject: [PATCH] sftp: seek: Don't flush buffers if the requested offset is the same as current

[PATCH] sftp: seek: Don't flush buffers if the requested offset is the same as current

From: Richard W.M. Jones <rjones_at_redhat.com>
Date: Tue, 26 Mar 2013 16:58:03 +0000

I encountered a problem when adding libssh2 support to qemu:

http://lists.gnu.org/archive/html/qemu-devel/2013-03/msg04626.html

which was that my code always called libssh2_sftp_seek64 between every
request. Because the requests come randomly, this makes sense from
the point of view of making the code simple.

There seems to be an impact on performance in my measurements of
perhaps 1/5th - 1/3rd, and that appears to come down to libssh2
flushing readahead buffers when you call libssh2_sftp_seek64.

I since changed the code of qemu to avoid calling libssh2_sftp_seek64
unless it is necessary, but the patch I'm attaching here should at
least partially fix the problem at the libssh2 API level.

To be honest I'm having a hard time measuring the impact of this
change because the variability in my measurements is about the same as
the benefit I'm expecting to see. Nevertheless the change should be
obviously correct by inspection, so I don't see what harm it would do.

Rich.

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2013-03-26