Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
e65a19bc
Commit
e65a19bc
authored
Aug 25, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
c32f1c78
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
6 deletions
+11
-6
go/neo/client/cache.go
go/neo/client/cache.go
+9
-4
go/neo/client/cache_test.go
go/neo/client/cache_test.go
+2
-2
No files found.
go/neo/client/cache.go
View file @
e65a19bc
...
...
@@ -180,7 +180,7 @@ func (c *Cache) Prefetch(xid zodb.Xid) {
// rce will become ready.
//
// rceNew indicates whether rce is new and so loading on it has not been
// initiated yet. rce should be loaded with loadRCE.
// initiated yet.
If so
rce should be loaded with loadRCE.
func
(
c
*
Cache
)
lookupRCE
(
xid
zodb
.
Xid
)
(
rce
*
revCacheEntry
,
rceNew
bool
)
{
// loadSerial(serial) -> loadBefore(serial+1)
before
:=
xid
.
Tid
...
...
@@ -299,6 +299,7 @@ func (c *Cache) loadRCE(rce *revCacheEntry, oid zodb.Oid) {
}
// if rce & rceNext cover the same range -> drop rce
// (if we drop rce - no need to update c.lru as new rce is not on that list)
if
i
+
1
<
len
(
oce
.
rcev
)
{
rceNext
:=
oce
.
rcev
[
i
+
1
]
if
rceNext
.
loaded
()
&&
tryMerge
(
rce
,
rceNext
,
rce
,
oid
)
{
...
...
@@ -310,9 +311,12 @@ func (c *Cache) loadRCE(rce *revCacheEntry, oid zodb.Oid) {
}
// if rcePrev & rce cover the same range -> drop rcePrev
// (if we drop rcePrev we'll later remove it from c.lru when under c.gcMu)
var
rcePrevDropped
*
revCacheEntry
if
i
>
0
{
rcePrev
:=
oce
.
rcev
[
i
-
1
]
if
rcePrev
.
loaded
()
&&
tryMerge
(
rcePrev
,
rce
,
rce
,
oid
)
{
rcePrevDropped
=
rcePrev
δsize
-=
len
(
rcePrev
.
data
)
}
}
...
...
@@ -323,12 +327,13 @@ func (c *Cache) loadRCE(rce *revCacheEntry, oid zodb.Oid) {
c
.
gcMu
.
Lock
()
//xv1 := map[string]interface{}{"lru": &c.lru, "rce": &rce.inLRU}
//fmt.Printf("aaa:\n%s\n", pretty.Sprint(xv1))
if
rcePrevDropped
!=
nil
{
rcePrevDropped
.
inLRU
.
Delete
()
}
rce
.
inLRU
.
MoveBefore
(
&
c
.
lru
)
//xv2 := map[string]interface{}{"lru": &c.lru, "rce": &rce.inLRU}
//fmt.Printf("\n--------\n%s\n\n\n", pretty.Sprint(xv2))
//panic(1)
c
.
size
+=
δsize
if
c
.
size
>
c
.
sizeMax
{
// XXX -> run gc
...
...
@@ -456,7 +461,7 @@ func (oce *oidCacheEntry) newRevEntry(i int, before zodb.Tid) *revCacheEntry {
before
:
before
,
ready
:
make
(
chan
struct
{}),
}
rce
.
inLRU
.
Init
()
rce
.
inLRU
.
Init
()
// initially not on Cache.lru list
oce
.
rcev
=
append
(
oce
.
rcev
,
nil
)
copy
(
oce
.
rcev
[
i
+
1
:
],
oce
.
rcev
[
i
:
])
...
...
go/neo/client/cache_test.go
View file @
e65a19bc
...
...
@@ -182,8 +182,8 @@ func TestCache(t *testing.T) {
t
.
Helper
()
var
mruv
[]
*
revCacheEntry
for
hp
,
h
:=
&
c
.
lru
,
c
.
lru
.
prev
;
h
!=
&
c
.
lru
;
hp
,
h
=
h
,
h
.
prev
{
xv
:=
[]
interface
{}{
&
c
.
lru
,
h
.
rceFromInLRU
()}
debug
.
Print
(
xv
)
// &c.lru, h.rceFromInLRU())
//
xv := []interface{}{&c.lru, h.rceFromInLRU()}
//
debug.Print(xv) // &c.lru, h.rceFromInLRU())
if
h
.
next
!=
hp
{
t
.
Fatalf
(
"LRU list .next/.prev broken for
\n
h:
\n
%s
\n\n
hp:
\n
%s
\n
"
,
debug
.
Sprint
(
h
),
debug
.
Sprint
(
hp
))
...
...
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