gvfs r1217 - in trunk: . daemon
- From: alexl svn gnome org
- To: svn-commits-list gnome org
- Subject: gvfs r1217 - in trunk: . daemon
- Date: Fri, 1 Feb 2008 13:33:16 +0000 (GMT)
Author: alexl
Date: Fri Feb 1 13:33:16 2008
New Revision: 1217
URL: http://svn.gnome.org/viewvc/gvfs?rev=1217&view=rev
Log:
2008-02-01 Alexander Larsson <alexl redhat com>
* daemon/gvfsreadchannel.c:
Request larger buffers than the client requested
so for better network efficiency. (#512472)
Modified:
trunk/ChangeLog
trunk/daemon/gvfsreadchannel.c
Modified: trunk/daemon/gvfsreadchannel.c
==============================================================================
--- trunk/daemon/gvfsreadchannel.c (original)
+++ trunk/daemon/gvfsreadchannel.c Fri Feb 1 13:33:16 2008
@@ -44,6 +44,7 @@
{
GVfsChannel parent_instance;
+ guint read_count;
int seek_generation;
};
@@ -94,6 +95,32 @@
g_vfs_channel_get_backend (channel));
}
+/* Always request large chunks. Its very inefficient
+ to do network requests for smaller chunks. */
+static guint32
+modify_read_size (GVfsReadChannel *channel,
+ guint32 requested_size)
+{
+ guint32 real_size;
+
+ if (channel->read_count <= 1)
+ real_size = 16*1024;
+ else if (channel->read_count <= 2)
+ real_size = 32*1024;
+ else
+ real_size = 64*1024;
+
+ if (requested_size > real_size)
+ real_size = requested_size;
+
+ /* Don't do ridicoulously large requests as this
+ is just stupid on the network */
+ if (real_size > 512 * 1024)
+ real_size = 512 * 1024;
+
+ return real_size;
+}
+
static GVfsJob *
read_channel_handle_request (GVfsChannel *channel,
guint32 command,
@@ -118,9 +145,10 @@
switch (command)
{
case G_VFS_DAEMON_SOCKET_PROTOCOL_REQUEST_READ:
+ read_channel->read_count++;
job = g_vfs_job_read_new (read_channel,
backend_handle,
- arg1,
+ modify_read_size (read_channel, arg1),
backend);
break;
case G_VFS_DAEMON_SOCKET_PROTOCOL_REQUEST_CLOSE:
@@ -137,6 +165,7 @@
else if (command == G_VFS_DAEMON_SOCKET_PROTOCOL_REQUEST_SEEK_CUR)
seek_type = G_SEEK_CUR;
+ read_channel->read_count = 0;
read_channel->seek_generation++;
job = g_vfs_job_seek_read_new (read_channel,
backend_handle,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]