[ZODB-Dev] Sharing (persisted) strings between threads

Malthe Borch mborch at gmail.com
Wed Dec 8 09:40:48 EST 2010


On 8 December 2010 15:29, Jim Fulton <jim at zope.com> wrote:
> The hash table retains a reference to the strings in it.  The
> references aren't weak afaik.

The reference is removed by the custom string dealloc function when
the ref count falls to 0. Interned strings do not linger on.

> What are you thinking of as applications with non-trivial strings?

In content management apps for instance, you have many non-trivial
strings with content, be it shorter descriptions or text bodies.
That's a substantial amount of text if allocated in duplicate or more.

Actually, I think *text* is the only kind of data that ought to take
up significant memory. Binary data ought to be blobbed out of the
database and the rest is just site structure and object overhead.

> The only one I can think of is template source.  That might be better
> served by either storing the source compressed or even storing it in a separate
> object that doesn't need to be in memory except when editing or compiling.

It might make sense to keep a global cache for ZODB-persisted
templates. But I'm not sure if there are so many that it's a burden
directly. This is an app-specific matter though.

I'll try to get some raw numbers out of currently running apps to make
the conversation more substantial.

\malthe


More information about the ZODB-Dev mailing list