On 1/3/11 14:47 , Wichert Akkerman wrote:
Pyramid seems to do a fair number of system calls when you use resource
overrides. For every page view in a site I have I see this in an strace:

[pid 15784]
stat("/srv/software/buildout/src/m18.site/m18/site/ui/templates/common.html",
{st_mode=S_IFREG|0644, st_size=52940, ...}) = 0
[pid 15784] lstat("/srv", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
[pid 15784] lstat("/srv/software", {st_mode=S_IFDIR|0755, st_size=4096,
...}) = 0
[pid 15784] lstat("/srv/software/buildout", {st_mode=S_IFDIR|0755,
st_size=4096, ...}) = 0
[pid 15784] lstat("/srv/software/buildout/src", {st_mode=S_IFDIR|0755,
st_size=4096, ...}) = 0
[pid 15784] lstat("/srv/software/buildout/src/m18.site",
{st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
[pid 15784] lstat("/srv/software/buildout/src/m18.site/m18",
{st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
[pid 15784] lstat("/srv/software/buildout/src/m18.site/m18/site",
{st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
[pid 15784] lstat("/srv/software/buildout/src/m18.site/m18/site/ui",
{st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
[pid 15784]
lstat("/srv/software/buildout/src/m18.site/m18/site/ui/templates",
{st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
[pid 15784]
lstat("/srv/software/buildout/src/m18.site/m18/site/ui/templates/common.html",
{st_mode=S_IFREG|0644, st_size=52940, ...}) = 0

this only seems to happen for that single template, which is an XInclude
used from chameleon.genshi. Does this ring a bell for anyone?

This turned out to be caused by the XInclude hack from pyramid_genshi, in particular this bit:

    filename = os.path.realpath(filename)
    template = self.registry.get(filename)


os.path.realpath does all those lstats. The three possible fixes I can see are:

1. do not bother doing os.path.realpath and accept a few duplicates in
   the registry
2. add a very stupid cache for os.path.realpath(filename) to the
   instance
3. write a braindead os.path.realpath which only resolves relative paths
   (ie turn '/one/two/thr33/../three' into '/one/two/three')

The second option is probably my favourite. If nobody comes up with an alternative I'll implement that and give Chris a patch.

Wichert.

--
You received this message because you are subscribed to the Google Groups 
"pylons-devel" group.
To post to this group, send email to pylons-de...@googlegroups.com.
To unsubscribe from this group, send email to 
pylons-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/pylons-devel?hl=en.

Reply via email to