There would be no point in having lots of threads per page of buffered I/O being fetched internally in the operating system - this would if anything be slower. The default buffered I/O page size for unix is 4096 bytes. But the processing of a 4096 byte buffer is apt to take less time than reading it from disk. So the threads would have to wait for each other anyway if they are allocated different pages from the same I/O stream (no gain there). Unless an extra pipe is inserted between the file I/O and the process, in which case the I/O system can make it's best effort to pump data down the pipe while your threads pick up 4K chunks and run with them to free the pipe more regularly for new data to replace it. But threads each seeking http://perldoc.perl.org/functions/seek.html to a different 4096 byte boundary of the shared filehandle need not work as expected. Forks would at least have the advantage of avoiding potential competition for internal I/O resources that I fear threads would encounter - somehow I feel that therefore forks offer a more hopeful scenario. But, given that there are more process overheads to forks, a trade-off multiplier (greater than 1) of how many 4K pages per fork will be optimal needs to be calculated. That might require experimentation.

One world, one people


In reply to Re: threading a perl script by anonymized user 468275
in thread threading a perl script by Boetsie

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.