[Zope-dev] Cache code in Shared/DC/ZRDB/DA.py
chris at simplistix.co.uk
Mon Nov 20 02:46:40 EST 2006
Dieter Maurer wrote:
>> - in line 368, why is len(cache)>max_cache/2 used as a trigger to start
>> cache clearing? (the /2 in particular)
> You may want to start getting rid of keys old enough that you would not
> use them anyway already before you reached max cache.
Yeah, I've changed some of the other code now so that when an entry is
found to be stale, it's dumped out of the cache immediately.
> And of course, it is quite stupid to determine the keys and reverse
> them, even when no key is old enough....
Yes, 2 things:
- The original Bucket class used died so long ago that just a simple
dict was being used, and this has no meaningful order.
- there's no need to delete the keys anyway, just delete from the other end.
>> - does it matter that IOBTree.Bucket has gone away and that tcache is
>> now a simple dictionary? It certainly seems to make the keys.reverse()
>> on line 370 superfluous and the keys[-1]<t on line 371 less reliable.
> Yes. You want to kill the dict and use the "IOBucket"...
Actually I used OOBucket. The silly casting-time-to-int just so it could
be used as the key for an IOBucket was a source of 2 memory leaks.
> If you are at it.
> The idea to have this cache maintained via a "_v_" attribute
> is insane. A module level cache would be much more efficient
> and save memory as well.
Can you explain this a bit more? I'm unlikely to have further time to do
this as well, but you're welcome to pick up where I left off...
Simplistix - Content Management, Zope & Python Consulting
More information about the Zope-Dev