[ZODB-Dev] ZODB cache reimplementation
Toby Dickenson
tdickenson@geminidataloggers.com
Wed, 30 Jan 2002 10:40:00 +0000
On Monday 28 January 2002 7:09 pm, Jeremy Hylton wrote:
>Toby,
>
>Can you provide a brief overview of how the new cache is designed. I
>tried to read the code
The UML Jim posted last week is a good start... and I hope to have something
to share (that actually corresponds to my implementation ;-) later this week.
>, but I wasn't sure what you were doing to use
>less memory
The goal is *not* to use less memory per object.
The old implementation was poor at responding to "memory pressure". I define
"memory pressure" as mean number of objects touched between calls to the
incremental garbage collecter. For zope, that is the same as objects touched
per request.
Note that this is nothing to do with the rate of requests.
Under memory pressure the old implementation could not move objects out of
memory fast enough, and the cache size would grow to a size roughly
proportional to memory pressure. Also, it would start to deactive even
recently used objects, in a desperate attempt to reduce the cache size.
>and couldn't reverse engineer the architecture from the
>implementation.
>
>It also looks like you haven't done the LRU part yet, right?
No, thats there.
the Persistent object struct has a new member 'ring' of type 'struct
CPersistentRing', which contains pointers for a doubly-linked-list which
encodes the lru order. (Its called 'ring' because both ends are linked back
to another CPersistentRing in the cPickleCache).
All the places that previously updated the 'atime' member now call the
'accessed' function from cPersistenceCAPI, which relinks the object to the
start of the ring.
I hope this helps.