P is for Practical | |
PerlMonks |
Re^9: Consumes memory then crashsby BrowserUk (Patriarch) |
on Mar 25, 2012 at 09:36 UTC ( [id://961476]=note: print w/replies, xml ) | Need Help?? |
my point was merely that threaded code is hard to get right ... If you don't follow the rules, the simplest things can screw up:
And here's a bit of the output: Don't blame Perl or threads because your C runtime libraries are paying lip service to the realities of concurrency. If it doesn't take care of things, you'll have to do it. The addition of my $old = select $fh; $|++; select $old; might sort out the interleaving problem. And use threads stack_size => 4096; will substantially reduce the memory footprint. But that's all irrelevant. Like saying a bendy-bus is 25x better than a family car because it can carry 100 people. The 500 do-almost-nothing threads in Not my code! And what is the point of running 500 threads? It takes ~40MB to run 4 threads. That's a whole 2% of the ram of the lowest spec commodity box you'll ever find for sale. And with 4 threads, it takes:
51 seconds to pull 501 names. With 8 threads:
49 seconds. So doubling the number of threads gained almost nothing. The pipe or the remote server is the limiting factor. I'd love to compare like with like, but having installed the 131 file that make up the POE behemoth:
I was still missing stuff your script needed:
So, then I tried to download that, but one of its dozen or so dependancies was unavailable:
It might take a bit less memory, but it certainly won't be quicker because the limitation is the pipe and/or remote server. I guess I could try installing the 270 module mojo behemothe, but it never terminates:
One way uses 0.5% of my memory; only needs what came installed with my Perl installation; and works. The other two require gobs of extra code and either don't run or never finish. The decision is an easy one for me. All that's left for me to do is free up about 50 MB of space on my harddrive by throwing away all the crap installed to write this post:
There, all done. With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
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 Section
Seekers of Perl Wisdom
|
|