Re: Is Perl supposed to use 100% of the CPU?
From: Sherm Pendley (spamtrap_at_dot-app.org)
Date: 03/31/04
- Next message: Gunnar Hjalmarsson: "Re: Array from a string."
- Previous message: Thomas Kratz: "Re: Lost data on socket - Can we start over politely?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Gunnar Hjalmarsson: "Re: Array from a string."
- Previous message: Thomas Kratz: "Re: Lost data on socket - Can we start over politely?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|