Re: python readlines() is slow when run in an apache2 cgi running in a vserver
So, I finally solved my problem[1].
Darcsweb was slow under vserver because python dup2 is slow when
ulimit -H -n is high : closing all those fd's in a python loop is
slow, see Lib/popen2.py in the python source that says :
for i in xrange(3, MAXFD):
try:
os.close(i)
And in a vserver, the default ulimit -H -n which is RLIMIT_NOFILE is
1024^2. This means that MAXFD is also 1024^2 and that the loop is
long.
This does not happen on a Gentoo box because the gentoo apache2
initscript does not use apache2ctl whereas debian does. And because of
this magic line in /usr/sbin/apache2ctl :
ULIMIT_MAX_FILES="ulimit -S -n `ulimit -H -n`"
soft limits become hard and apache gains 1024^2 max fd's.
Thanks to the good guys at #vserver irc channel, I fixed my slowness doing :
echo 1024 >/etc/vservers/<guest>/ulimits/nofile.hard
I still do not know where this 1024 on the host or this 1024^2 on the
guest come from, but my problem is fixed.
Cheers everybody,
Alexandre
[1] http://lists.debian.org/debian-user/2007/01/msg02688.html
Reply to: