summaryrefslogtreecommitdiff
path: root/daemon/gvfsreadchannel.c
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2008-02-01 13:33:16 +0000
committerAlexander Larsson <alexl@src.gnome.org>2008-02-01 13:33:16 +0000
commite44b47796547f652d3a1479721082fa2e3d2a2fc (patch)
tree74bf0a451c744a01dfb2570dac9ebac81b56b8ef /daemon/gvfsreadchannel.c
parent766ec5eb48c477c6870d558febfc11ba3540a429 (diff)
downloadgvfs-e44b47796547f652d3a1479721082fa2e3d2a2fc.tar.gz
Request larger buffers than the client requested so for better network
2008-02-01 Alexander Larsson <alexl@redhat.com> * daemon/gvfsreadchannel.c: Request larger buffers than the client requested so for better network efficiency. (#512472) svn path=/trunk/; revision=1217
Diffstat (limited to 'daemon/gvfsreadchannel.c')
-rw-r--r--daemon/gvfsreadchannel.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/daemon/gvfsreadchannel.c b/daemon/gvfsreadchannel.c
index bedc1436..ea49f4ff 100644
--- a/daemon/gvfsreadchannel.c
+++ b/daemon/gvfsreadchannel.c
@@ -44,6 +44,7 @@ struct _GVfsReadChannel
{
GVfsChannel parent_instance;
+ guint read_count;
int seek_generation;
};
@@ -94,6 +95,32 @@ read_channel_close (GVfsChannel *channel)
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 @@ read_channel_handle_request (GVfsChannel *channel,
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 @@ read_channel_handle_request (GVfsChannel *channel,
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,