httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dan Yamins <dyam...@gmail.com>
Subject [users@httpd] Dot extremely slow when called from python cgi script
Date Sat, 25 Apr 2009 16:23:04 GMT
I'm having a problem with performance of the program "dot" (for rendering
graphs) when called from a python cgi script, served by an apache virtual
host.  I'm writing this email both the apache httpd list as well as the
graphviz users lists (hoping some intersection might be useful).

I'm using OSX 10.5.6 and graphviz2.22 (built via macports).

When I run a simple python script that calls dot (via a system call) to
render a small graph, it takes about .04 seconds, which is normal.  But when
I run the same call via CGI script it takes roughly 100 times longer (4
seconds).     I've tried graphs of various sizes, ranging from very tiny
graphs (4 nodes) to much larger graphs.   The 4 seconds figure for the CGI
script doesn't change much except for very large graphs, so the time spent
in the CGI script is probably not coming from the actual rendering itself.

Not all system calls in my CGI scripts take longer than their "regular
called at the prompt" version (e.g. if I do a simple 'pwd' it is comparable
in time when called in the CGI script versus the non-served script.   (And
many others perform fine.)   The problem just seems to be with the graphviz
dot executable.

Below are the two test scripts that when run on my machine illustrate the
problem.

Any help (from either community) would be great.

Thanks!
Dan


Here's the python script: run as "python test.py"

------test.py-----------------
import os, time

T = time.time()
os.system('/opt/local/bin/dot -Tsvg -o test.svg graph.dot')
print time.time() - T               #output here is 0.04 seconds
T = time.time()
os.system('pwd > testout.txt')
print time.time() - T               #output here is 0.003 seconds


Here's the CGI script:  run by navigating to the proper URL for the virtual
host on my local machine

------test.cgi----------------

#!/Library/Frameworks/Python.framework/Versions/Current/bin/python

import time
import cgi, os

print 'Content-Type: text/html; charset=utf-8\n\n'
os.chdir('../../Temp')
T = time.time()
os.system('/opt/local/bin/dot -Tsvg -o test.svg graph.dot')
print time.time() - T                 #output here is like 4 seconds
T = time.time()
os.system('pwd > testout.txt')
print time.time() - T                #output here is 0.003 seconds

Mime
View raw message