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
4cc99c49
Commit
4cc99c49
authored
Mar 12, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
6436e1dc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
48 deletions
+66
-48
go/zodb/persistent.go
go/zodb/persistent.go
+1
-1
go/zodb/persistent_test.go
go/zodb/persistent_test.go
+65
-47
No files found.
go/zodb/persistent.go
View file @
4cc99c49
...
@@ -276,7 +276,7 @@ func (obj *Persistent) PDeactivate() {
...
@@ -276,7 +276,7 @@ func (obj *Persistent) PDeactivate() {
return
return
}
}
// TODO cp & PCache
NonTemporal
-> drop unconditionally; otherwise -> LRU
// TODO cp & PCache
DropState | PCacheDropObject
-> drop unconditionally; otherwise -> LRU
obj
.
serial
=
InvalidTid
obj
.
serial
=
InvalidTid
obj
.
istate
()
.
DropState
()
obj
.
istate
()
.
DropState
()
...
...
go/zodb/persistent_test.go
View file @
4cc99c49
...
@@ -727,16 +727,20 @@ func TestLiveCache(t0 *testing.T) {
...
@@ -727,16 +727,20 @@ func TestLiveCache(t0 *testing.T) {
tdb
.
Add
(
101
,
"мир"
)
tdb
.
Add
(
101
,
"мир"
)
tdb
.
Add
(
102
,
"труд"
)
tdb
.
Add
(
102
,
"труд"
)
tdb
.
Add
(
103
,
"май"
)
tdb
.
Add
(
103
,
"май"
)
tdb
.
Add
(
104
,
"весна"
)
tdb
.
Commit
()
tdb
.
Commit
()
at1
:=
tdb
.
head
at1
:=
tdb
.
head
zcc
:=
&
zcacheControl
{
map
[
Oid
]
PCachePolicy
{
zcc
:=
&
zcacheControl
{
map
[
Oid
]
PCachePolicy
{
// obj1 - don't pin and don't keep state (default)
// obj1 - default (currently: don't pin and don't keep state)
// TODO: it should go into LRU on release, not dropped
101
:
0
,
101
:
0
,
// obj
2
- pin and keep state
// obj
PK
- pin and keep state
102
:
PCachePinObject
|
PCacheKeepState
,
102
:
PCachePinObject
|
PCacheKeepState
,
// obj3 - pin, but don't keep state
// objPD - pin, but don't keep state
103
:
PCachePinObject
|
PCacheNonTemporal
,
103
:
PCachePinObject
|
PCacheDropState
,
// objDD - drop object and state
104
:
PCacheDropObject
|
PCacheDropState
,
}}
}}
t
:=
tdb
.
Open
(
&
ConnOptions
{})
t
:=
tdb
.
Open
(
&
ConnOptions
{})
...
@@ -746,58 +750,72 @@ func TestLiveCache(t0 *testing.T) {
...
@@ -746,58 +750,72 @@ func TestLiveCache(t0 *testing.T) {
zcache
.
Unlock
()
zcache
.
Unlock
()
// get objects
// get objects
obj1
:=
t
.
Get
(
101
)
obj
:=
t
.
Get
(
101
)
obj2
:=
t
.
Get
(
102
)
objPK
:=
t
.
Get
(
102
)
obj3
:=
t
.
Get
(
103
)
objPD
:=
t
.
Get
(
103
)
t
.
checkObj
(
obj1
,
101
,
InvalidTid
,
GHOST
,
0
)
objDD
:=
t
.
Get
(
104
)
t
.
checkObj
(
obj2
,
102
,
InvalidTid
,
GHOST
,
0
)
t
.
checkObj
(
obj
,
101
,
InvalidTid
,
GHOST
,
0
)
t
.
checkObj
(
obj3
,
103
,
InvalidTid
,
GHOST
,
0
)
t
.
checkObj
(
objPK
,
102
,
InvalidTid
,
GHOST
,
0
)
t
.
checkObj
(
objPD
,
103
,
InvalidTid
,
GHOST
,
0
)
t
.
checkObj
(
objDD
,
104
,
InvalidTid
,
GHOST
,
0
)
// activate * -> uptodate
// activate * -> uptodate
t
.
PActivate
(
obj1
)
t
.
PActivate
(
obj
)
t
.
PActivate
(
obj2
)
t
.
PActivate
(
objPK
)
t
.
PActivate
(
obj3
)
t
.
PActivate
(
objPD
)
t
.
checkObj
(
obj1
,
101
,
at1
,
UPTODATE
,
1
,
"мир"
)
t
.
PActivate
(
objDD
)
t
.
checkObj
(
obj2
,
102
,
at1
,
UPTODATE
,
1
,
"труд"
)
t
.
checkObj
(
obj
,
101
,
at1
,
UPTODATE
,
1
,
"мир"
)
t
.
checkObj
(
obj3
,
103
,
at1
,
UPTODATE
,
1
,
"май"
)
t
.
checkObj
(
objPK
,
102
,
at1
,
UPTODATE
,
1
,
"труд"
)
t
.
checkObj
(
objPD
,
103
,
at1
,
UPTODATE
,
1
,
"май"
)
// deactivate obj{1,3} drop state, obj2 is kept
t
.
checkObj
(
objDD
,
104
,
at1
,
UPTODATE
,
1
,
"весна"
)
obj1
.
PDeactivate
()
obj2
.
PDeactivate
()
// deactivate obj{,PD,DD} drop state, objPK is kept
obj3
.
PDeactivate
()
obj
.
PDeactivate
()
t
.
checkObj
(
obj1
,
101
,
InvalidTid
,
GHOST
,
0
)
objPK
.
PDeactivate
()
t
.
checkObj
(
obj2
,
102
,
at1
,
UPTODATE
,
0
,
"труд"
)
objPD
.
PDeactivate
()
t
.
checkObj
(
obj3
,
103
,
InvalidTid
,
GHOST
,
0
)
objDD
.
PDeactivate
()
t
.
checkObj
(
obj
,
101
,
InvalidTid
,
GHOST
,
0
)
t
.
checkObj
(
objPK
,
102
,
at1
,
UPTODATE
,
0
,
"труд"
)
t
.
checkObj
(
objPD
,
103
,
InvalidTid
,
GHOST
,
0
)
t
.
checkObj
(
objDD
,
104
,
InvalidTid
,
GHOST
,
0
)
// live cache should keep pinned object live even if we drop all
// live cache should keep pinned object live even if we drop all
// regular pointers to it and do GC.
// regular pointers to it and do GC.
obj1
.
_v_cookie
=
"peace"
obj
.
_v_cookie
=
"peace"
obj2
.
_v_cookie
=
"labour"
objPK
.
_v_cookie
=
"labour"
obj3
.
_v_cookie
=
"may"
objPD
.
_v_cookie
=
"may"
obj1
=
nil
objDD
.
_v_cookie
=
"spring"
obj2
=
nil
obj
=
nil
obj3
=
nil
objPK
=
nil
objPD
=
nil
objDD
=
nil
for
i
:=
0
;
i
<
10
;
i
++
{
for
i
:=
0
;
i
<
10
;
i
++
{
runtime
.
GC
()
// need only 2 runs since cache uses finalizers
runtime
.
GC
()
// need only 2 runs since cache uses finalizers
}
}
xobj1
:=
zcache
.
Get
(
101
)
xobj
:=
zcache
.
Get
(
101
)
xobj2
:=
zcache
.
Get
(
102
)
xobjPK
:=
zcache
.
Get
(
102
)
xobj3
:=
zcache
.
Get
(
103
)
xobjPD
:=
zcache
.
Get
(
103
)
assert
.
Equal
(
xobj1
,
nil
)
xobjDD
:=
zcache
.
Get
(
104
)
assert
.
NotEqual
(
xobj2
,
nil
)
assert
.
Equal
(
xobj
,
nil
)
assert
.
NotEqual
(
xobj3
,
nil
)
assert
.
NotEqual
(
xobjPK
,
nil
)
obj2
=
xobj2
.
(
*
MyObject
)
assert
.
NotEqual
(
xobjPD
,
nil
)
obj3
=
xobj3
.
(
*
MyObject
)
assert
.
Equal
(
xobjDD
,
nil
)
t
.
checkObj
(
obj2
,
102
,
at1
,
UPTODATE
,
0
,
"труд"
)
objPK
=
xobjPK
.
(
*
MyObject
)
t
.
checkObj
(
obj3
,
103
,
InvalidTid
,
GHOST
,
0
)
objPD
=
xobjPD
.
(
*
MyObject
)
t
.
checkObj
(
objPK
,
102
,
at1
,
UPTODATE
,
0
,
"труд"
)
assert
.
Equal
(
obj2
.
_v_cookie
,
"labour"
)
t
.
checkObj
(
objPD
,
103
,
InvalidTid
,
GHOST
,
0
)
assert
.
Equal
(
obj3
.
_v_cookie
,
"may"
)
assert
.
Equal
(
objPK
.
_v_cookie
,
"labour"
)
obj1
=
t
.
Get
(
101
)
assert
.
Equal
(
objPD
.
_v_cookie
,
"may"
)
t
.
checkObj
(
obj1
,
101
,
InvalidTid
,
GHOST
,
0
)
assert
.
Equal
(
obj1
.
_v_cookie
,
""
)
obj
=
t
.
Get
(
101
)
objDD
=
t
.
Get
(
104
)
t
.
checkObj
(
obj
,
101
,
InvalidTid
,
GHOST
,
0
)
t
.
checkObj
(
objDD
,
104
,
InvalidTid
,
GHOST
,
0
)
assert
.
Equal
(
obj
.
_v_cookie
,
""
)
assert
.
Equal
(
objDD
.
_v_cookie
,
""
)
}
}
// TODO Map & List tests.
// TODO Map & List tests.
...
...
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