Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Multithreaded Script CPU Usage

by BrowserUk (Pope)
on Aug 26, 2008 at 00:44 UTC ( #706809=note: print w/ replies, xml ) Need Help??


in reply to Multithreaded Script CPU Usage

I suspect that your cpu usage problem is related to this failure when running the Thread::Pool::Simple test suite:

c:\Perl\packages\Thread-Pool-Simple-0.23>nmake test Microsoft (R) Program Maintenance Utility Version 7.00.9466 Copyright (C) Microsoft Corporation. All rights reserved. C:\Perl\bin\perl.exe "-MExtUtils::Command::MM" "-e" "test_harn +ess(0, 'blib\lib', 'blib\arch')" t\1.t t\2.t t\3.t t\4.t t\1....ok 1/0Can't call method "down" on unblessed reference at C:\Per +l\packages\Thread-Pool-Simple-0.23\blib\lib/Thread/Pool/Simple.pm lin +e 39. # Looks like your test died just after 1. t\1....dubious Test returned status 255 (wstat 65280, 0xff00) after all the subtests completed successfully t\2....ok 1/0Can't call method "down" on unblessed reference at C:\Per +l\packages\Thread-Pool-Simple-0.23\blib\lib/Thread/Pool/Simple.pm lin +e 39. # Looks like your test died just after 1. t\2....dubious Test returned status 255 (wstat 65280, 0xff00) after all the subtests completed successfully t\3....ok 1/0Can't call method "down" on unblessed reference at C:\Per +l\packages\Thread-Pool-Simple-0.23\blib\lib/Thread/Pool/Simple.pm lin +e 39. # Looks like your test died just after 1. t\3....dubious Test returned status 255 (wstat 65280, 0xff00) after all the subtests completed successfully t\4....ok 1/0Can't call method "down" on unblessed reference at C:\Per +l\packages\Thread-Pool-Simple-0.23\blib\lib/Thread/Pool/Simple.pm lin +e 39. # Looks like your test died just after 1. t\4....dubious Test returned status 255 (wstat 65280, 0xff00) after all the subtests completed successfully Failed Test Stat Wstat Total Fail Failed List of Failed ---------------------------------------------------------------------- +--------- t\1.t 255 65280 1 0 0.00% ?? t\2.t 255 65280 1 0 0.00% ?? t\3.t 255 65280 1 0 0.00% ?? t\4.t 255 65280 1 0 0.00% ?? Failed 4/4 test scripts, 0.00% okay. 0/4 subtests failed, 100.00% okay +. NMAKE : fatal error U1077: 'C:\Perl\bin\perl.exe' : return code '0x2' Stop.

This failure can be traced to this line from the T::P::S code:

my $self = &share({});

Which make the T:::P::S object a shared hash. The problem is that when a few lines later, it creates an instance of Thread::Semaphore and stores the returned handle into that hash:

$self->{shutdown_lock} = Thread::Semaphore->new();

Because the hash is shared, the blessedness of the Thread::Semaphore object is lost. Ie. It stops being a blessed scaler and becomes a plain ordinary scalar. And when it attempts to call a methd on that scalar:

$self->{shutdown_lock}->down(); ## line 39

it fails (Note:The line number is different because I added some debug:

???SCALAR(0x19a690c) Can't call method "down" on unblessed reference at C:\Perl\packages\Thread-Pool-Simple-0.23\blib\lib/Thread/Pool/Simple.p +m line 43.

This is a newly introduced bug that didn't exist when I tried T::P::Simple a few few weeks ago. Now, you can "fix" this test failure by upgrading to the latest CPAN versions of threads and threads::shared.

Unfortunately, with that upgrade, as with so many of the releases ever since they were dual lived, comes a different set of problems. The T::P::Simple now completes all its tests, but leaks memory like a sieve:

c:\Perl\packages\Thread-Pool-Simple-0.23>nmake test Microsoft (R) Program Maintenance Utility Version 7.00.9466 Copyright (C) Microsoft Corporation. All rights reserved. C:\Perl\bin\perl.exe "-MExtUtils::Command::MM" "-e" "test_harn +ess(0, 'blib\lib', 'blib\arch')" t\1.t t\2.t t\3.t t\4. t\1....ok 1/0Scalars leaked: 1 Scalars leaked: 1 Scalars leaked: 1 Scalars leaked: 1 Scalars leaked: 1 Scalars leaked: 1 Scalars leaked: 1 Scalars leaked: 1 Scalars leaked: 1 Scalars leaked: 1 t\1....ok t\2....ok 901/0Scalars leaked: 1 Scalars leaked: 1 Scalars leaked: 1 Scalars leaked: 1 Scalars leaked: 1 t\2....ok t\3....ok 901/0Scalars leaked: 1 Scalars leaked: 1 Scalars leaked: 1 Scalars leaked: 1 Scalars leaked: 1 Scalars leaked: 1 Scalars leaked: 1 Scalars leaked: 1 Scalars leaked: 1 Scalars leaked: 1 Scalars leaked: 1 Scalars leaked: 1 Scalars leaked: 1 Scalars leaked: 1 Scalars leaked: 1 Scalars leaked: 1 Scalars leaked: 1 Scalars leaked: 1 Scalars leaked: 1 Scalars leaked: 1 t\3....ok t\4....ok 2/0Scalars leaked: 1 t\4....ok All tests successful. Files=4, Tests=1805, 20 wallclock secs ( 0.00 cusr + 0.00 csys = 0.0 +0 CPU)

Which wouldn't be so bad if T::P::Simple was the only module affected, but with the latest versions of threads & threads::shared, programs that ran completely clean with 5.8.6 and its distributed version of threads/threads::shared, now leak like a sieve also..


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.


Comment on Re: Multithreaded Script CPU Usage
Select or Download Code
Re^2: Multithreaded Script CPU Usage
by Zenshai (Sexton) on Aug 26, 2008 at 18:42 UTC
    Im not sure what's different in our test environments, but I seem to be having no problems in any of the tests for T::P::S

    This is what I get:
    D:\Perl\MSWin32-x86-multi-thread-5.8\Thread-Pool-Simple-0.23>nmake tes +t Microsoft (R) Program Maintenance Utility Version 1.50 Copyright (c) Microsoft Corp 1988-94. All rights reserved. D:\Perl\bin\perl.exe "-MExtUtils::Command::MM" "-e" "test_harn +ess(0, 'blib\lib', 'blib\arch')" t/*.t t/1....ok t/2....ok t/3....ok t/4....ok All tests successful. Files=4, Tests=1805, 16 wallclock secs ( 0.00 cusr + 0.00 csys = 0.0 +0 CPU)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://706809]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (16)
As of 2014-08-27 18:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (248 votes), past polls