Though these are microoptimizations, consider consolidating your tr/// calls to my $Total = $DNA =~ tr/ACGT//;. Make your s/GC/GC/g and s/AT/AT/g calls look like this instead: my $GC = () = $DNA =~ m/GC/g;, and in the while loop, avoid making throwaway copies of the sequence that are only used once.

The bigger issue really is that you're not as processor bound as you might think you are in the portion of the code you shifted into subprocesses. It's likely that if you were to profile (Devel::NYTProf) the code before you converted it to a forking solution, you would discover most of the time is spent making $seqio->next_seq calls in the while loop, and that's one area where there's not much you can do about it.

That call is reading from a stream, and the stream probably has bandwidth limited by the characteristics of the device you are reading from, and forking would be minimally effective or even negatively impactful at the reading stage.

If you are processing many files, you might be able to spread the gathering of those files across several physical devices and then fork a child for each file you wish to process. No single file would run faster, but the overall effect would probably produce savings.


Dave


In reply to Re: Perl::ForkManager does not speed up ATCG calculation !! by davido
in thread Perl::ForkManager does not speed up ATCG calculation !! by jnarayan81

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.