VariableSchemaSupport unnecessary slow
Roché Compaan <roche-kb4xc5yObU3kQYj/0HfcvhBnub05S5/[email protected]> Wed, 14 Jun 2006 09:32:59 +0200
| Newsgroups | gmane.comp.web.zope.plone.archetypes.devel |
|---|---|
| Organization | Upfront Systems |
| Message-ID | <[email protected]> |
Hi there
Yesterday some of my colleagues and I ran profiler while re-indexing
content types that subclass VariableSchemaSupport. We discovered that
the hash created when caching the schema is making things very very
slow. Here is the relevant code:
# create a hash value out of the schema
hash=sha.new(str([f.__dict__ for f in s.values()]) +
str(self.__class__)).hexdigest()
I understand that the above code ensures that we always have a fresh
schema and that nobody else has to do anything in their code, but the
price on has to pay in performance is simply to high. I would recommend
that we use a very simple mechanism where the schema is cached upon
access and invalidated when it changes.
Our profiling showed that after fixing this, VariableSchemaSupport can
be just as fast as plain schemas. To give you and idea, we reindexed
1000 Person instances and it took more than 10 minutes before, and just
30 seconds after the fix.
--
Roché Compaan
Upfront Systems http://www.upfrontsystems.co.za