My method avoids that flocking problem...

There was no flocking problem until you created it.

Its simple:

Simple? Take 1 big input file and split it into N bits.

Run N thread reading those N bits (concurrently, causing the disk head to dance all over the disk), and then write all the records read down N pipes.

Then have a select loop that brings all the records from all the pipes back together in a single thread before deciding what to do with them.

You really don't see that all you've achieved with those 10 threads and 10 pipes is the equivalent of:

while( <HUGEFILE> ) { ... }

Except it will run at least 10 times more slowly, regardless of how many cores your processor has!

That really isn't just glaringly obvious to you?

This is simple. And fast. And platform independent.

No threads. No pipes. No pointless select loop (which doesn't work with pipes on some platforms anyway)...


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re^12: how to split huge file reading into multiple threads by BrowserUk
in thread how to split huge file reading into multiple threads by sagarika

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.