in reply to Re^9: Consumes memory then crashs
in thread Consumes memory then crashs
Don't fret over the couple of kilobytes of crap® you had to download. I installed a whole Strawberry Perl just to test your code on Windows :)
Don't blame Perl or threads because your C runtime libraries are paying lip service to the realities of concurrency.
Assuming this to be the case, I have bad news for you: so does Windows' C library. Here's a snippet of your "fixed" code's output on the latest Strawberry on XP---the runtime was just as atrocious as on Linux BTW:
$ uniq -c outfile |head -n10 819 Thread 2 1 ThThread 1 818 Thread 1 1 ThThread 3 818 Thread 3 1 ThThread 4 818 Thread 4 1 ThThread 5 818 Thread 5 1 ThThread 6
At Thread 20 it gets a bit more irregular ...
If it doesn't take care of things, you'll have to do it.
No, you'll have to do it. If you want to show it can be done correctly using threading that is.
The addition of my $old = select $fh; $|++; select $old; might sort out the interleaving problem.
That doesn't sound overly confident ...
And what is the point of running 500 threads?
Contrary to what you wrote, a thread is not just a means of improving efficiency on multiprocessors. It's just a logical program flow that's supposed to correspond to a certain task, and there are plenty of tasks that could make use of hundreds of threads: simulations, network monitoring, sensor data collection, crawling slow sites, etc. If threading in the "use threads" sense was halfway efficient for it that is.
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.
You still get 1 GB netbooks, but whatever. So you need only twice the memory to get correct results most of the time, with nondeterministic failures in-between, after the first "Service Pack". At least the other side's IIS doesn't seem to scale either so you don't have to put the thread code to this test. Sorry, even though I have conceded from the start that there are rare cases where threads are the model of choice this is not gonna convince me that we're looking at one.
As for POE on Windows, on my fresh Strawberry install I can type "cpan POE" and then "cpan POE::Component::Client::HTTP" to end up with a working installation of everything required. Don't blame POE when ActiveState's repository absorbs excrement.
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.
No, it does not work, at least not reliably. That was the whole point. The failure rate may be acceptable for you but I don't think it's "a simple solution to thread this properly" as the OP asked.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^11: Consumes memory then crashs
by BrowserUk (Patriarch) on Mar 26, 2012 at 03:56 UTC | |
by mbethke (Hermit) on Mar 26, 2012 at 20:52 UTC | |
by BrowserUk (Patriarch) on Mar 26, 2012 at 20:59 UTC | |
by mbethke (Hermit) on Mar 26, 2012 at 21:05 UTC | |
by BrowserUk (Patriarch) on Mar 26, 2012 at 21:18 UTC |