]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
msg/simple: apply prefetch policy more precisely 10344/head
authorxie xingguo <xie.xingguo@zte.com.cn>
Tue, 19 Jul 2016 07:48:21 +0000 (15:48 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Tue, 19 Jul 2016 08:04:43 +0000 (16:04 +0800)
We shall apply prefetch policy based on the residual length aftering
checking cache instead of the original request length.

E.g., if the reading sequences are 1K, 5K, 2K, the improved logic
will trigger another prefetch of 4K(as 5K - 3K(from recv_buf) == 2K, and we
now have 8K prefetched data total) by the second 5K reading(which we
don't do this according to the old logic), and thus the last reading request
which asks for 2K data can be also benefited from this prefetch too,
which is good for performance.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/msg/simple/Pipe.cc

index 2c2efb097f7b591b73583df853a5bff76392b7c1..4a6bb0173daecd94f3a6c66c5a1a3eeb7064d974 100644 (file)
@@ -2554,7 +2554,7 @@ ssize_t Pipe::buffered_recv(char *buf, size_t len, int flags)
 
   /* nothing left in the prefetch buffer */
 
-  if (len > (size_t)recv_max_prefetch) {
+  if (left > (size_t)recv_max_prefetch) {
     /* this was a large read, we don't prefetch for these */
     ssize_t ret = do_recv(buf, left, flags );
     if (ret < 0) {