Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
497c0fae
Commit
497c0fae
authored
Mar 11, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
a365cf6e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
11 deletions
+26
-11
go/zodb/connection.go
go/zodb/connection.go
+18
-7
go/zodb/persistent.go
go/zodb/persistent.go
+8
-4
No files found.
go/zodb/connection.go
View file @
497c0fae
...
...
@@ -113,8 +113,11 @@ type LiveCache struct {
// Hopefully we don't have cycles with BTree/Bucket.
sync
.
Mutex
objtab
map
[
Oid
]
*
weak
.
Ref
// oid -> weak.Ref(IPersistent); potentially have a referee
pinned
map
[
Oid
]
IPersistent
// objects that are pinned and don't have any referee currently
// pinned objects. may have referees.
pinned
map
[
Oid
]
IPersistent
// not pinned objects. may have referees.
objtab
map
[
Oid
]
*
weak
.
Ref
// oid -> weak.Ref(IPersistent)
// hooks for application to influence live caching decisions.
control
LiveCacheControl
...
...
@@ -198,6 +201,7 @@ func (e *wrongClassError) Error() string {
// Get lookups object corresponding to oid in the cache.
//
// 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.
func
(
cache
*
LiveCache
)
Get
(
oid
Oid
)
IPersistent
{
wobj
:=
cache
.
objtab
[
oid
]
var
obj
IPersistent
...
...
@@ -216,14 +220,14 @@ func (cache *LiveCache) Get(oid Oid) IPersistent {
// set sets objects corresponding to oid.
func
(
cache
*
LiveCache
)
set
(
oid
Oid
,
obj
IPersistent
)
{
var
pc
PCachePolicy
// XXX -> cp, pol? ... ?
var
cp
PCachePolicy
if
cc
:=
cache
.
control
;
cc
!=
nil
{
pc
=
cache
.
control
.
PCacheClassify
(
obj
)
cp
=
cache
.
control
.
PCacheClassify
(
obj
)
}
// XXX remember
pc
in obj .pcachePolicy?
// XXX remember
cp
in obj .pcachePolicy?
// XXX del .objtab[oid] ?
// XXX del .pinned[oid] ?
if
pc
&
PCachePinObject
!=
0
{
if
cp
&
PCachePinObject
!=
0
{
cache
.
pinned
[
oid
]
=
obj
}
else
{
cache
.
objtab
[
oid
]
=
weak
.
NewRef
(
obj
)
...
...
@@ -250,7 +254,14 @@ func (cache *LiveCache) forEach(f func(IPersistent)) {
// It is not safe to call SetControl simultaneously to other cache operations.
func
(
cache
*
LiveCache
)
SetControl
(
c
LiveCacheControl
)
{
cache
.
control
=
c
// XXX reclassify all objects
// reclassify all objects
c2
:=
*
cache
cache
.
objtab
=
make
(
map
[
Oid
]
*
weak
.
Ref
)
cache
.
pinned
=
make
(
map
[
Oid
]
IPersistent
)
c2
.
forEach
(
func
(
obj
IPersistent
)
{
cache
.
set
(
obj
.
POid
(),
obj
)
})
}
// get is like Get, but used when we already know object class.
...
...
go/zodb/persistent.go
View file @
497c0fae
...
...
@@ -262,20 +262,24 @@ func (obj *Persistent) PDeactivate() {
// no constant load/unload on object access. XXX -> MRU cache?
// NOTE wcfs manages its objects explicitly and does not need this.
var
cp
PCachePolicy
if
cc
:=
obj
.
jar
.
cache
.
control
;
cc
!=
nil
{
// XXX catch inconsistency in PCacheClassify result
// XXX locking for .control ?
cp
:=
cc
.
PCacheClassify
(
obj
.
instance
)
cp
=
cc
.
PCacheClassify
(
obj
.
instance
)
}
if
cp
&
PCacheKeepState
!=
0
{
return
}
}
// already ghost
if
obj
.
state
==
GHOST
{
return
}
// XXX cp & PCacheNonTemporal -> drop unconditionally; otherwise -> LRU
obj
.
serial
=
InvalidTid
obj
.
istate
()
.
DropState
()
obj
.
state
=
GHOST
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment