Commit 9817744d authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 368bb3f7
...@@ -147,9 +147,9 @@ const ( ...@@ -147,9 +147,9 @@ const (
// //
// This allows to rely on object being never evicted from live cache. // This allows to rely on object being never evicted from live cache.
// //
// Note: object's state can still be evicted and the object can go into // Note: object's state can still be discarded and the object can go
// ghost state. Use PCacheKeepState to prevent such automatic eviction // into ghost state. Use PCacheKeepState to prevent such automatic
// until it is really needed. // state eviction until discard is really needed.
PCachePinObject PCachePolicy = 1 << iota PCachePinObject PCachePolicy = 1 << iota
// don't discard object state. // don't discard object state.
...@@ -160,8 +160,8 @@ const ( ...@@ -160,8 +160,8 @@ const (
// data access is non-temporal. // data access is non-temporal.
// //
// Object state is used once and then won't be used for a long time. // Object's state is used once and then won't be used for a long time.
// Don't pollute cache with this object state. // Don't pollute cache with state of this object.
PCacheNonTemporal // XXX PCacheForgetState? DropState? PCacheNonTemporal // XXX PCacheForgetState? DropState?
) )
...@@ -173,8 +173,8 @@ func newConnection(db *DB, at Tid) *Connection { ...@@ -173,8 +173,8 @@ func newConnection(db *DB, at Tid) *Connection {
db: db, db: db,
at: at, at: at,
cache: LiveCache{ cache: LiveCache{
objtab: make(map[Oid]*weak.Ref),
pinned: make(map[Oid]IPersistent), pinned: make(map[Oid]IPersistent),
objtab: make(map[Oid]*weak.Ref),
}, },
} }
} }
...@@ -204,14 +204,14 @@ func (e *wrongClassError) Error() string { ...@@ -204,14 +204,14 @@ func (e *wrongClassError) Error() string {
// If object is found, it is guaranteed to stay in live cache while the caller keeps reference to it. // If object is found, it is guaranteed to stay in live cache while the caller keeps reference to it.
// LiveCacheControl can be used to extend that guarantee. // LiveCacheControl can be used to extend that guarantee.
func (cache *LiveCache) Get(oid Oid) IPersistent { func (cache *LiveCache) Get(oid Oid) IPersistent {
// 1. lookup in pinned objects (potentially hottest) // 1. lookup in pinned objects (likely hottest ones)
obj := cache.pinned[oid] obj := cache.pinned[oid]
if obj != nil { if obj != nil {
return obj return obj
} }
// 2. lookup in referenced object (they are likely to be loaded as // 2. lookup in !pinned referenced object (they are likely to be loaded
// other objects reference them) // going from a referee)
wobj := cache.objtab[oid] wobj := cache.objtab[oid]
if wobj != nil { if wobj != nil {
if xobj := wobj.Get(); xobj != nil { if xobj := wobj.Get(); xobj != nil {
...@@ -219,12 +219,13 @@ func (cache *LiveCache) Get(oid Oid) IPersistent { ...@@ -219,12 +219,13 @@ func (cache *LiveCache) Get(oid Oid) IPersistent {
} }
} }
// 3. TODO lookup in non-referenced LRU // 3. TODO lookup in non-referenced LRU cache
return obj return obj
} }
// set sets objects corresponding to oid. // set sets objects corresponding to oid.
// XXX -> setNew?
func (cache *LiveCache) set(oid Oid, obj IPersistent) { func (cache *LiveCache) set(oid Oid, obj IPersistent) {
var cp PCachePolicy var cp PCachePolicy
if cc := cache.control; cc != nil { if cc := cache.control; cc != nil {
......
...@@ -278,7 +278,7 @@ func (obj *Persistent) PDeactivate() { ...@@ -278,7 +278,7 @@ func (obj *Persistent) PDeactivate() {
return return
} }
// XXX cp & PCacheNonTemporal -> drop unconditionally; otherwise -> LRU // TODO cp & PCacheNonTemporal -> drop unconditionally; otherwise -> LRU
obj.serial = InvalidTid obj.serial = InvalidTid
obj.istate().DropState() obj.istate().DropState()
......
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