S
skyn3t
I have a perl cgi script that reads from the network and outputs about
40K per second to the caller.
The script is averaging about 15-25% CPU utilization, when it isn't
doing much other than reading from the network, parsing the message,
and printing it. I want to get this CPU utilization down.
Things I have tried:
(1) Use SmallProf/DProf to get profiling information on the script and
make adjustments. I made quite a few perl optimizations based on this
data and it barely dented the CPU utilization.
(2) Convert the script to use sysread() to read the data in larger
chunks than the perlio libs do. This did not change the CPU
utilization at all.
(3) Select on the socket before attempting reading from it, and bail
if there is no data. Didn't help CPU.
So what's causing it? I'm stumped.
Here is what a 2 minute "time" call to my script looks like:
real 2m8.469s
user 0m1.557s
sys 0m0.795s
Should I be worried about the large discrepancy between the real time
and the user+sys time? This indicates that perl is idling quite a bit,
correct? Is this normal for a perl application?
Any thoughts on how I can determine where the CPU utilization is
coming from?
40K per second to the caller.
The script is averaging about 15-25% CPU utilization, when it isn't
doing much other than reading from the network, parsing the message,
and printing it. I want to get this CPU utilization down.
Things I have tried:
(1) Use SmallProf/DProf to get profiling information on the script and
make adjustments. I made quite a few perl optimizations based on this
data and it barely dented the CPU utilization.
(2) Convert the script to use sysread() to read the data in larger
chunks than the perlio libs do. This did not change the CPU
utilization at all.
(3) Select on the socket before attempting reading from it, and bail
if there is no data. Didn't help CPU.
So what's causing it? I'm stumped.
Here is what a 2 minute "time" call to my script looks like:
real 2m8.469s
user 0m1.557s
sys 0m0.795s
Should I be worried about the large discrepancy between the real time
and the user+sys time? This indicates that perl is idling quite a bit,
correct? Is this normal for a perl application?
Any thoughts on how I can determine where the CPU utilization is
coming from?