[Twisted-Python] Re: Twisted 1.0.4 - Heavy search for `plugins.tml'

Tommi Virtanen tv at twistedmatrix.com
Mon Apr 28 03:12:57 EDT 2003

On Sun, Apr 27, 2003 at 08:28:48PM -0400, Francois Pinard wrote:
> Usually, `/usr/bin/' and such do not have subdirectories, so if a
> directory contains 1000 entries, one may immediately check if one of
> these is `plugins.tml' by a direct try.  Then, if the number of links of
> that directory -- itself -- is exactly 2, we can conclude that it has no
> sub-directories, and that there is nothing more to check for this one.
> We could then get more speed even for directories other than `/usr/bin/'.

	The important thing is to make that optimization disabled if
	link count != 2. That is, in any other case you really need
	to go through the stat calls.

> But I do not remember if Linux existed at the time.  As Linux seems to
> beat many other systems at properly caching disk accesses, the benefits
> of the trick might be more hidden.  A year ago, maybe, I tried the same
> trick on Linux in hope of increasing the performance of `os.path.walk',
> and the speed-up was not so significant.  This is part of my hesitation.

	A Linux box with enough memory should have really good stat
	performance with a hot cache. For /usr/bin, it may be that
	the cache is mostly hot anyway. But even Linux will suffer
	the same performance problems with a cold cache or too little
	RAM to cache much.

:(){ :|:&};:

More information about the Twisted-Python mailing list