tish15 has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I need some help with finding the root cause of perl threads high cpu usage.

The high cpu usage started occurring when I used multithreading. And its only the parent and the child threads that are causing the CPU usage of approx 80%. There are few more perl processess running on the system and they don't even appear in the output of 'top'.

I am using the following modules for implementation:

Acme-Damn-0.04

Devel-Symdump-2.08

Sys-SigAction-0.11

forks-0.33

Can anyone guide me through this problem?

Thanks

Replies are listed 'Best First'.
Re: perl threads causing high cpu usage
by Anonymous Monk on Jul 16, 2010 at 07:10 UTC
    Can anyone guide me through this problem?

    A joke namespace (Acme) and mixing forks , signals, and threads .... the words "bottomless tarpit quicksand" spring to mind, but I'm not an expert :)

    The advice on asking questions still applies, start by writing a minimal self-contained program that reproduces your unwanted behaviour

    Good luck

      U mean to say that using Acme with the other modules is the cause?

        I don't think that's what AM meant... but the mish-mash you cite might do most anything with the possible exception of teaching pigs to fly.

        From the Acme::Damn documentation:

        "Acme::Damn provides a single routine, damn(), which takes a blessed reference (a Perl object), and unblesses it, to return the original reference. I can't think of any reason why you might want to do this, but just because it's of no use doesn't mean that you shouldn't be able to do it."

        It's a really good practice read the docs for all your modules. Reading the rest of those is left as an exercise to tish15. And as AM mentioned, it's really hard to help solve a problem like this (to say nothing of 'hard to find any inventive to do so') without seeing your problem code.

        Before posting code though, and before jumping to more unfounded conclusions, please see On asking for help and How do I post a question effectively?.

        I fugured out the problem area... My parent thread, after forking child threads is running in while(1) loop... I have done this because at times I need to send signal to the parent thread and hence need the parent thread to continue to exist...

        Is there anyway to make the parent thread dormant but continue to exist

Re: perl threads causing high cpu usage
by BrowserUk (Patriarch) on Jul 16, 2010 at 09:39 UTC

    It's the loop on line 271.