[Zope-dev] (ZPatterns) Speeding up Skinscripts

John Eikenberry jae-zdev@kavi.com
Thu, 29 Mar 2001 13:57:01 -0800


We have a fairly large and complex app framework built on ZPatterns. It
uses MySQL for storage and the standard Specialist/Rack/DataSkin setup with
skinscripts for attributes and triggers.

We've found that the speed of getItem is a bit slower than we need. For
instance retrieving 200 dataskins takes about 8 seconds on a P2-300. After
profiling and digging around I think I've found the primary bottleneck. Its the
running of eval() on the skinscript's python expression (stored in the Compute
class as _fromex and Triggers as callexpr).

Note that this becomes the bottleneck after the SQL Method gets cached. The
query to the DB takes the most time on the first hit, but after its been cached
it takes very little time.

The optimization I've been looking at is changing the code from storing a
string and eval()ing the string to using compile() at save time and exec() when
evaluated.

Profiling these 2 ways in little test programs seems to indicate about a 2.5x
speedup. Not huge, but combined with better hardware should be enough.

But I'm curious why this avenue wasn't taken to begin with. Seems like the way
to do it to me. Am I missing something? 

-- 

John Eikenberry [jae@kavi.com]
______________________________________________________________
"A society that will trade a little liberty for a little order
 will deserve neither and lose both."
                                          --B. Franklin