Each of these requests in an uncached world would mean one hit for a probably tiny chunk of data on the remote server side, resulting in quick and useless concurrent hits. Thus, I've put a simple caching mechanism into the loop

But you're not in an uncached world. Perl already does buffering. It's a small buffer (4k), so you might still want to do your own buffering (although you should use probably use sysread if you do).

Now reading begins, and depending on the application doing the read() it asks for chunks of 1, 46, 1024, whatever bytes of data - efficient when done on local disk, inefficient over network.

No, read returns data from the handle's buffer. If the buffer doesn't hold enough data, read requests 4k chunks until it has the requested amount of data or an error occurs.

This differs from sysread. sysread ignores what's in the buffer, requests the amount of bytes you specified from the OS, and returns whatever the OS returned (which may be less than the requested amount even if no error occurs).

The problem in this solution is that the local script needs to be able to read() and seek() in a data structure

Perl's does read-ahead buffering. It won't help if you seek around. (Maybe if you seek a little forward, but that's it.) You still need a solution for that.

Update: Added last para.


In reply to Re: Advice needed on an interesting read-ahead over network file IO problem by ikegami
in thread Advice needed on an interesting read-ahead over network file IO problem by isync

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.