Commit 4b71bba0 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 5683c3ca
......@@ -457,18 +457,22 @@ func (bf *BigFile) Read(_ nodefs.File, dest []byte, off int64, _ fuse.Context) (
*/
// zodbCacheControl tunes ZODB wrt caching XXX
// zodbCacheControl implements ConnCacheControl to tune ZODB to never evict
// ZBTree/ZBucket from live cache. We want to keep ZBTree/ZBucket always alive
// becuse it is essentially the index where to find ZBigFile data.
//
// For the data itself - we put it to kernel cache and always deactivate from
// ZODB right after that.
//
// XXX set it to Connection.CacheControl
type zodbCacheControl struct {}
type (cc *zodbCacheControl) WantEvict(obj Object) {
// we want to keep ZBTree/ZBucket always alive becuse it is essentially
// the index where to find ZBigFile data.
func (cc *zodbCacheControl) WantEvict(obj Object) {
switch obj.(type) {
default:
return true
case *ZBtree:
case *ZBTree:
case *ZBucket:
}
......
......@@ -18,6 +18,7 @@ import (
"context"
"fmt"
"sync"
"sync/atomic"
"lab.nexedi.com/kirr/neo/go/zodb"
......@@ -106,7 +107,7 @@ func (pyobj *pyObject) PyState() interface{} { return pyobj.pystate }
// ConnCacheControl is the interface that allows applications to influence
// Connection decisions with respect to its cache.
// Connection's decisions with respect to its live cache.
type ConnCacheControl interface {
// WantEvict is called when object is going to be evicted from live cache and made ghost.
// If !ok the object will remain live.
......@@ -178,6 +179,9 @@ type Connection struct {
objmu sync.Mutex
objtab map[zodb.Oid]*WeakRef // oid -> WeakRef(PyObject)
//objtab map[zodb.Oid]interface{} // oid -> WeakRef(pyObject) | loadInProgress
cacheControl ConnCacheControl
}
/*
......@@ -493,7 +497,7 @@ func (obj *object) pactivate(ctx context.Context) error {
nuse := atomic.AddInt32(&obj.refcnt, +1)
if nuse == 1 {
// we become responsible for loading object's data.
// XXX check .tryToKeepInRam
// XXX check state
}
}
......@@ -509,6 +513,12 @@ func (obj *object) pdeactivate() {
// no users left. Let's see whether we should transition this object to ghost.
// TODO state=modified -> don't drop.
if drop {
if cc := obj.jar.cacheControl; cc != nil {
drop = cc.WantEvict(obj)
}
}
if drop {
obj.serial = 0
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment