in reply to My CGI is slow, but I don't think it's my fault.

It probably just means the database on your host is very slow. How about showing us the rest of that DProf output, sorted by wall time? Then it would be obvious where the time was going.
  • Comment on Re: My CGI is slow, but I don't think it's my fault.

Replies are listed 'Best First'.
Re^2: My CGI is slow, but I don't think it's my fault.
by jimt (Chaplain) on Mar 03, 2007 at 16:05 UTC

    And Perrin gets the gold star. Right on both counts.

    Re-profiling with dprofpp -r (d'oh. There's an option which I'll need to remember) yielded:

    Total Elapsed Time = 22.28669 Seconds Real Time = 22.28669 Seconds Exclusive Times %Time ExclSec CumulS #Calls sec/call Csec/c Name 59.2 13.20 13.200 314 0.0420 0.0420 DBI::db::ping

    Basically, every time it tried to grab a cached database handle, it would ping it first to make sure it was still valid. Useful in persistent environments (mod_perl, etc.) or long running scripts, but not so much on a website that's all CGI and nothing survives long. I figured I could take the risk of having the database handle vanish in that time, so I shut off the constant re-pinging.

    Next profile dropped the total run time down to 5.45 seconds, with 83% of my time spent executing queries. Much more reasonable. And I'm sure I can get that runtime down even farther with some judicious indexing.

    Thanks!