Re: Is Perl supposed to use 100% of the CPU?

From: Sherm Pendley (spamtrap_at_dot-app.org)
Date: 03/31/04


Date: Wed, 31 Mar 2004 10:24:33 -0500

Ron Bean wrote:

> The question is: Is it supposed to use so much of the CPU?

Perl, by itself, uses 0% CPU.

A badly-written Perl script, just like a badly-written program in any other
language, can use up 100% of your CPU and beg for more.

> Any ideas as to get my site speed back up?

Sure, three simple steps:

1. Figure out what script is swamping your server. If there is only one
script, it's obviously the culprit. If XP provides some means of listing
CPU usage for Perl scripts individually, do that. Otherwise, look to see if
any of the scripts on the system have been added or changed recently. As a
last resort, take scripts offline one at a time, observing the CPU load
each time. When removing one of them reduces the load, you've found the
culprit.

2. Profile the problem script to determine where it's slow. Take care of the
low-hanging fruit first; i.e. see what's changed recently. For example, if
the script was running fine, but a new function to calculate foo was added
and now it's bog-slow, then that function is what you should be looking at.
You could also use Devel::DProf to profile your code.

3. Fix it. This is an exercise left to the reader. ;-)

> Or am I looking at building a dedicated *nix box to run it?

Building one in hopes that it will magically make some unknown problem
disappear is pointless. Figure out what the problem is *first*, then figure
out what needs to be done to fix it.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


Relevant Pages

  • [NEWS] IBM Informix Web DataBlade Local Root by Design
    ... The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com ... that ease development of "intelligent", interactive, Web-enabled database ... person who has access to change the Perl script. ...
    (Securiteam)
  • Re: is it possible to efficiently read a large file?
    ... The performance Mark is seeing ... the difference in CPU usage between dd bs=128k and the perl script ... Next I'd check what the perl script is really doing. ...
    (comp.lang.perl.misc)
  • my perl script for ripping mp3s...aka MP3scRIPt
    ... This is a Perl script to convert audio cd tracks to mp3s. ... Possibly root privs to access the cdrom device ... - this is mainly a problem on 'variety cds', mp3 files suffering from this ill ...
    (comp.unix.bsd.freebsd.misc)
  • Re: Perl script to mimic uniq
    ... mdfoster44@netscape.net spits TOFU in my face: ... > # Perl script to find most common CS ... > So I'm back to my original script which looks like this. ... > identify a sequence as unique. ...
    (comp.lang.perl)
  • Re: Slow Performance When Using DBI, otherwise Not
    ... If I run the same perl script on the database server itself it runs ... check versions of DBI and DBD (I greped for version on every module under ...
    (perl.dbi.users)