title: Do network file systems pre-fetch ? (Or: Do Internet File System make optimizations to reduce round trips)
body: <p>Take the following code snippit:</p>
  
  <pre><code> f = open("/mnt/remoteserver/bar/foo.bin", O_RDONNLY);
   while (true)
   {
         byteseread = read(f, buffer, 1000);
         if (bytesread &gt; 0)
             ProcessBytes(buffer, bytesread);
         else
             break;
    }
  </code></pre>
  
  <p>If the example above, let's say the remote file, foo.bin is 1MB and has never been accessed by the client before. So, that's approximately 1000 calls to "read" to get the entire file.</p>
  
  <p>Further, let's say the server with the directory mounted on the client is over the internet and not local.  Fast bandwidth to the client, but with long latency.</p>
  
  <p>Does every "read" call invoke a round trip back to the server to ask for more data?  Or does the client/server protocol recognize that subsequent reads on a remote file are often sequential, and as such, subsequent blocks are pushed down before the application has actually made a read() call for it. Hence, subsequent read calls return faster because the data was pre-fetched and cached.</p>
  
  <p>Do modern network file system protocols (NFS, SMB/Samba, any others?) make any optimizations like this.  Are there network file system protocols tuned for the internet that have optimizations like this?  </p>
  
  <p>I'm investigating a personal project that may involve implementation of a network file system over the internet. It struck me that performance may be faster if the number of round trips could be reduced for file i/o.</p>