[Zope-CMF] Re: Making TypesTool faster

Tres Seaver tseaver at palladion.com
Wed May 2 22:02:02 EDT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Alexander Limi wrote:
> On Wed, 02 May 2007 10:03:39 -0700, Martin Aspeli  
> <optilude at gmx.net> wrote:
> 
>> +1, but I don't think the two need to be mutually exclusive.
> 
> Amen.
> 
>> At present, Archetypes-based content types cannot be used with a factory  
>> (I
>> tried hard, but there are some acquisition-related/factory related  
>> reasons);
>> I'd like to refactor this, but we can't for Plone 3.0 at least.
> 
> Right. Obviously, we'd like to do this "the proper way", but we can't do  
> that for a while yet.

I do have a notion which would make this "better, faster, stronger" for
Plone, which is much more afflicted by this problem than other CMF-based
sites (because it presents an add menu on each page):  I think the
bottleneck is actually inside 'ATContentTypes.lib.contraintypes', in the
'getDefaultAddableTypes' method of the 'ConstrainTypesMixin' class:  it
could cache the typeinfo list (or a list of mappings derived from it),
with the container and the user_id as keys.

Most of the win would come immediatelely, and at the place most affected
by the clurrent slowness, leaving us time to figure out why Z3-style
factories don't work with AT.

>> Given that Alec & co essentially had a patch which worked, I suggest  
>> that we
>> have a look at it, and include it if possible, and then encourage the use
>> factories in general. I'd hope we could avoid deprecating it outright  
>> until
>> we can fix up AT to use them, though.
> 
> Also note that according to Alec, it would work better as a instance-level  
> thing than a thread-level one.

The cache is actually based only on the container (which could be a
path) and the user ID.  It would be a perfect use of a RAM Cache Manager
 (assuming that we cached mappings rather than persistent references).
Using a volatile here (which is what I assume you mean) would dilute the
"locality" of the cache by the number of database connections in use.

I've looksd, and all the callers of 'getDefaultAddableTypes' need only
the ID and / or the title of the FTI, which simplifies things a bunch.

> Isn't this something like 2 lines of code in TypesTool? :)

I don't think so.  Getting the tests right is likely to be *lots* of
lines of code in 'tests/test_TypesTool.py', if we make the change there.


Tres.
- --
===================================================================
Tres Seaver          +1 540-429-0999          tseaver at palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGOUKa+gerLs4ltQ4RAoVvAJ9KeQJ6yBYVfvZnG9QMh5hdJ/Q6pACfZLbd
+yihEEAEXfTMV4pYyA8ixbI=
=kVBV
-----END PGP SIGNATURE-----



More information about the Zope-CMF mailing list