[gvfs] daemons: Tweak read sizes



commit 20406034ca71ca24c39eec1a7b4b6878eb3f204b
Author: Alexander Larsson <alexl redhat com>
Date:   Fri Apr 5 14:33:21 2013 +0200

    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.

 daemon/gvfsreadchannel.c |   25 ++++++++++++++++++-------
 1 files changed, 18 insertions(+), 7 deletions(-)
---
diff --git a/daemon/gvfsreadchannel.c b/daemon/gvfsreadchannel.c
index 092f728..f219ded 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;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]