[ZODB-Dev] Cannot make ZEO cache work on RO transactions

Hector Sanchez SanMartin Hector.Sanchez at cern.ch
Tue Aug 10 05:20:39 EDT 2004


    Hello everybody,

    I'm trying to set up the ZEO client cache in persistent mode but I 
noticed a strange behaviour for which I cannot find an explanation: the 
client cache seems not to be correctly set up if no object is modified 
during a transaction. This is probably due to a wrong use of the DB I'm 
doing so I'll try to illustrate it with an example to see if someone can 
help me.
    I have written a small piece of code which populates a db with 
simple objects and then a small script that fetches those objects and 
enabled the ZEO cache tracing in order to see what happens. The code 
which fetches the objects is as follows:
...
    
s=ClientStorage(("mymachine",9675),var="c:/tmp/testDBPerformance/",client="cache")
    db=DB(s)
    conn=db.open()
    root=conn.root()
    bc=root["books"]
    l=_fetchAll(bc) #fetch some objects from the sample DB
    get_transaction().commit()

     This code works fine and the cache files are created on the 
specified target. When I run the analyser I got a hit rate of 0.2% 
(1,068 loads, 2 hits,  0.2% hit rate) which is normal as no cache file 
existed and therefore every object need to be fetched from the DB. If I 
run it a second time, to my understanding it should find the objects in 
the local cache so the hit rate should be higher; I run the analyser and 
I find that the hit rate is still 0.2% (1,068 loads, 2 hits, 0.2% hit 
rate). It seems the cache is doing nothing.
    Now I delete the cache files and modify the code so there's a 
modified object within the transaction:
...
    
s=ClientStorage(("mymachine",9675),var="c:/tmp/testDBPerformance/",client="cache")
    db=DB(s)
    conn=db.open()
    root=conn.root()
    mark=root.get("mark",0)
    root["mark"]=mark+1 #simple modification
    bc=root["books"]
    l=_fetchAll(bc) #fetch some objects from the sample DB
    get_transaction().commit()

    Again, I run the code once so the cache files are created and the 
analyser gives me a hit rate of 0.2% (1,068 loads, 2 hits, 0.2% hit 
rate) which is normal. I run it a second time and the hit rate has 
increased to 50.1% (1,068 loads, 1,068 hits,100.0% hit rate) which seems 
to be the behaviour I expected.

    Is there any reason why it didn't work on the first case? Am I doing 
something wrong with the DB management which makes the cache files not 
to be valid?

    Thanks a lot in advance for your help

-- 
Hector Sanchez

CERN Document Server ** <http://cds.cern.ch/> ** <cds.support at cern.ch>
InDiCo Project       ** <http://cern.ch/indico>
Room: Bldg 513-R-027 ** Voice: +41-22-7677918



More information about the ZODB-Dev mailing list