betabug... Sascha Welter

home english | home deutsch | Site Map | Sascha | Kontakt | Pro | Weblog | Wiki

22 January 2010

Want: Memory Optimization for ZWiki

Back to ZWiki hacking: An evening at the code
Mist on the edge of the Parnasos mountains in Greece

Yesterday evening for the first time in a looong time I got busy with ZWiki source code. I had checked out the latest darcs code and was basically looking to improve something in a general way, not just fix bugs. One such point is memory use optimization and a field I don't know that much about yet. A chance to learn combined with a chance to do a good deed... here I come!

The concept is basically to find cases where we store (large) data in basic attributes on one of our objects. Zope loads these "secondary objects" into memory, as soon as it loads the main object. Once you "move them out" into objects that are derived from "persistent", Zope will load them only when they are directly accessed. kosh (of #zope fame) explained the concept famously some time ago.

My first bet was the actual page content: It can be big and it will only be really needed when we actually display the page, not when we access the page object to get information e.g. for the contents page or for showing the page title in some page list. Unfortunately the content is "hidden" in the DTMLmethod object ZWikiPage is based on, so I can't easily mess with it. But there is another candidate: The "prerender cache" we use to store the "halfbaked" html to get page content rendered faster.

So, yesterday I managed in a few lines to create a simple object to store that cache (basically a big string) and attach it to the ZWiki page object whenever needed. It all works and passes all the tests, but I have yet to prove that it will save memory use in the long run and on large wikis. The current very experimental code is in my ZWiki darks repository - not meant for production use in any way! (... and of course if you find this post a few months from now, it might well not be in there any more.)

Posted by betabug at 09:39 | Comments (0) | Trackbacks (0)
ch athens
Life in Athens (Greece) for a foreigner from the other side of the mountains. And with an interest in digital life and the feeling of change in a big city. Multilingual English - German - Greek.
Main blog page
Recent Entries
Best of
Some of the most sought after posts, judging from access logs and search engine queries.

Apple & Macintosh:
Security & Privacy:
Misc technical:
Athens for tourists and visitors:
Life in general:
<< Eislaufen oder nicht Eislaufen | Main | Ένα ξεχωριστό πάρτι >>
There are no comments.
You can trackback to:
There are no trackbacks.