Try this and see how you get on?

On my system with only dialup bandwidth I used HEAD requests and parsed local content (32kb HTML with ~1000 links). The result is that with 10 threads, it consumes ~40MB of ram and achieves >80% cpu usage. Using more threads is pointless, even fetching only head requests. That pretty much saturates my dialup connection.

YMMV depending on the size of the downloads, complexity of the processing and what other modules you need to load. Along with the number of cpus and your bandwidth. Feedback appreciated.

#! perl -slw use strict; use threads; use threads::shared; $|++; ## Important to prevent IO overlap our $NTHREADS ||= 10; ## Read test content from DATA 32kb html containing ~ 1000 links, ## Used for testing in conjunction with head() below. # my $content; { local $/; $content = <DATA>; } my $osync :shared; my $isync :shared; sub processEm { require LWP::Simple; LWP::Simple->import( 'head', 'get' ); require HTML::LinkExtor; my $tid = threads->self->tid; warn "$tid: starting"; while( my $url = do{ lock $isync; <STDIN> } ) { chomp $url; warn "$tid: processing $url"; ## Used for testing. A workaround my bandwidth limits ## and being a good netizen # head( $url ) or warn "Couldn't fetch $url" and next; my $content = get( $url ) or warn "Couldn't fetch $url" and ne +xt; my $l = HTML::LinkExtor->new( sub{ lock $osync; print "'$_[ 2 ]'"; } , $url ); $l->parse( $content ); } } open STDIN, '<', $ARGV[ 0 ] or die $!; my @threads = map{ threads->create( \&processEm ) } 1 .. $NTHREADS; $_->join for @threads; __END__ c:\test>663223.plt -NTHREADS=10 urls.txt >output.txt

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.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

In reply to Re: converting from process to threads by BrowserUk
in thread converting from process to threads by FromTheMotherland

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.