Sharing large volumes of data between threads, whether through threads::shared or tools (like Thread::Queue) that use the former, is simple not effective. It is a penalty of the ithread architecture that even if you only want to share data between 2 individual threads, every other thread in the process also gets a copy like it or not, use it or not.
On the face of it, two simple changes to your Win32 threaded code might sort the problems out.
- Have each thread retrieve the data from the url to an in-memory, *non-shared* buffer, and use a single semaphore (ie. a shared scalar) and threads::shared::lock() to ensure that only one thread writes to disk at a time.
- Create yourself a tperl.exe with a greatly reduce stacksize reservation as described in Use more threads.. With this reduced to 64k, you should find you are able to run many, many more concurrent threads.
I've had 3000 ithreads running and concurrently active, though they were not doing much at all. I would suggest that 100 or 200 would probably be enough to ensure that you are capable of using the full bandwidth available from your internet connection. Of course, the limitations are likely to be memory in which to hold the data prior to writing it to disc, rather than connection speed.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|