summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2013-04-05 14:33:21 +0200
committerAlexander Larsson <alexl@redhat.com>2013-04-05 14:33:21 +0200
commit20406034ca71ca24c39eec1a7b4b6878eb3f204b (patch)
tree4aabbc372f2943d2692a2d780c5666bf37987f85
parent4efd634afdb564b890e75404aefea5198e3b6487 (diff)
downloadgvfs-20406034ca71ca24c39eec1a7b4b6878eb3f204b.tar.gz
daemons: Tweak read sizes
Make sure we never read more than one page unless requested on the first read. This helps for e.g. sniffing and gstreamer (which reads in 4k blocks with seeks inbetween). Also, further limit the max size request, because 512k seems very ridicoulus.
-rw-r--r--daemon/gvfsreadchannel.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/daemon/gvfsreadchannel.c b/daemon/gvfsreadchannel.c
index 092f728d..f219ded2 100644
--- a/daemon/gvfsreadchannel.c
+++ b/daemon/gvfsreadchannel.c
@@ -96,27 +96,38 @@ read_channel_close (GVfsChannel *channel)
}
/* Always request large chunks. Its very inefficient
- to do network requests for smaller chunks. */
+ * to do network requests for smaller chunks.
+ *
+ * gstreamer tends to do 4k reads and seeks, and
+ * the first read when sniffing is also small, so
+ * it makes sense to never read more that 4k
+ * (one page) on the first read. It should not affect
+ * long-file copy performance anyway.
+ */
static guint32
modify_read_size (GVfsReadChannel *channel,
guint32 requested_size)
{
guint32 real_size;
-
+
if (channel->read_count <= 1)
- real_size = 16*1024;
+ real_size = 4*1024;
else if (channel->read_count <= 2)
+ real_size = 8*1024;
+ else if (channel->read_count <= 3)
+ real_size = 16*1024;
+ else if (channel->read_count <= 4)
real_size = 32*1024;
else
real_size = 64*1024;
-
+
if (requested_size > real_size)
- real_size = requested_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;
+ if (real_size > 128 * 1024)
+ real_size = 128 * 1024;
return real_size;
}