diff options
author | Alexander Larsson <alexl@redhat.com> | 2013-04-05 14:33:21 +0200 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2013-04-05 14:44:13 +0200 |
commit | e0941e88ffdd3b4d89e8d2db9dabbb86ff9d81e1 (patch) | |
tree | 99d812833f2404af474ce6960e9f26c9140fd0b3 | |
parent | c9b8fc094d7a95386641901957cca890d5345aa1 (diff) | |
download | gvfs-e0941e88ffdd3b4d89e8d2db9dabbb86ff9d81e1.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.c | 25 |
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; } |