Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
da05eb37
Commit
da05eb37
authored
Mar 31, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
58b5b848
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
16 deletions
+37
-16
wcfs/wcfs.go
wcfs/wcfs.go
+37
-16
No files found.
wcfs/wcfs.go
View file @
da05eb37
...
...
@@ -281,7 +281,8 @@ package main
// - if retrieved successfully -> store retrieved data back into OS file
// cache for @<rev>/bigfile/file[blk], where
//
// rev = max(δFtail.by(#blk)) || min(rev ∈ δFtail) || zhead.at ; see below about δFtail
// # see below about file.δtail
// rev = max(file.δtail.by(#blk)) || min(rev ∈ file.δtail) || zhead.at
//
// - invalidate head/bigfile/file[blk] in OS file cache.
//
...
...
@@ -300,15 +301,17 @@ package main
// 5) after OS file cache was invalidated, we resync zhead to new database
// view corresponding to tid.
//
// 6) for every file δ
F
tail invalidation info about head/data is maintained:
// 6) for every file δtail invalidation info about head/data is maintained:
//
// - tailv: [](rev↑, []#blk)
// - by: {} #blk -> []rev↑ in tail
//
// δ
F
tail.tail describes invalidations to file we learned from ZODB invalidation.
// δ
F
tail.by allows to quickly lookup information by #blk.
// δtail.tail describes invalidations to file we learned from ZODB invalidation.
// δtail.by allows to quickly lookup information by #blk.
//
// min(rev) in δFtail is min(@at) at which head/bigfile/file is currently mmapped (see below).
// min(rev) in δtail is min(@at) at which head/bigfile/file is currently mmapped (see below).
//
// XXX δtail can miss ...
//
// to support initial openings with @at being slightly in the past, we also
// make sure that min(rev) is enough to cover last 10 minutes of history
...
...
@@ -326,13 +329,13 @@ package main
// it is not exact because BTree/Bucket can change (e.g. rebalance)
// but still point to the same k->ZBlk.
//
// we also use file.δ
F
tail to find either exact blk revision:
// we also use file.δtail to find either exact blk revision:
//
// rev(blk) = max(file.δ
F
tail.by(#blk) -> []rev↑)
// rev(blk) = max(file.δtail.by(#blk) -> []rev↑)
//
// or another upper bound if #blk ∉ δ
F
tail:
// or another upper bound if #blk ∉ δtail:
//
// rev(blk) ≤ min(rev ∈ δ
Ftail) ; #blk ∉ δF
tail
// rev(blk) ≤ min(rev ∈ δ
tail) ; #blk ∉ δ
tail
//
//
// below rev'(blk) is min(of the estimates found):
...
...
@@ -345,7 +348,7 @@ package main
// - rev'(blk) ≤ at: -> do nothing
// - rev'(blk) > at:
// - if blk ∈ watcher.pinned -> do nothing
// - rev = max(δ
Ftail.by(#blk) : _ ≤ at) || min(rev ∈ δF
tail : rev ≤ at) || at
// - rev = max(δ
tail.by(#blk) : _ ≤ at) || min(rev ∈ δ
tail : rev ≤ at) || at
// - watcher.pin(file, #blk, @rev)
// - watcher.pinned += blk
//
...
...
@@ -513,7 +516,7 @@ type BigFile struct {
rev
zodb
.
Tid
// last revision that modified zfile data
// tail change history of this file.
δ
F
tail
*
ΔTailI64
// [](rev↑, []#blk)
δtail
*
ΔTailI64
// [](rev↑, []#blk)
// inflight loadings of ZBigFile from ZODB.
// successful load results are kept here until blkdata is put into OS pagecache.
...
...
@@ -919,7 +922,7 @@ func (f *BigFile) invalidateBlk(ctx context.Context, blk int64) (err error) {
if
int64
(
len
(
blkdata
))
==
blksize
{
func
()
{
// store retrieved data back to OS cache for file @<rev>/file[blk]
blkrev
,
_
:=
f
.
δ
F
tail
.
LastRevOf
(
blk
,
f
.
head
.
zconn
.
At
())
blkrev
,
_
:=
f
.
δtail
.
LastRevOf
(
blk
,
f
.
head
.
zconn
.
At
())
frev
,
frelease
,
err
:=
groot
.
mkrevfile
(
blkrev
,
f
.
zfile
.
POid
())
if
err
!=
nil
{
log
.
Errorf
(
"BUG: %s: invalidate blk #%d: %s (ignoring, but reading @revX/bigfile will be slow)"
,
f
.
path
(),
blk
,
err
)
...
...
@@ -1146,7 +1149,7 @@ func (f *BigFile) updateWatchers(ctx context.Context, blk int64, treepath []zodb
bfdir
.
indexLooked
.
Add
(
f
,
treepath
)
bfdir
.
indexMu
.
Unlock
()
blkrevmax
,
_
:=
f
.
δ
F
tail
.
LastRevOf
(
blk
,
f
.
zfile
.
PJar
()
.
At
())
// XXX = f.head.zconn.At()
blkrevmax
,
_
:=
f
.
δtail
.
LastRevOf
(
blk
,
f
.
zfile
.
PJar
()
.
At
())
// XXX = f.head.zconn.At()
blkrevmax
=
tidmin
(
blkrevmax
,
pathRevMax
)
wg
,
ctx
:=
errgroup
.
WithContext
(
ctx
)
...
...
@@ -1257,7 +1260,7 @@ func (w *Watch) pin(ctx context.Context, blk int64, rev zodb.Tid) (err error) {
}
// XXX comment
rev
,
_
=
w
.
file
.
δ
F
tail
.
LastRevOf
(
blk
,
w
.
at
)
rev
,
_
=
w
.
file
.
δtail
.
LastRevOf
(
blk
,
w
.
at
)
ack
,
err
:=
w
.
link
.
sendReq
(
ctx
,
fmt
.
Sprintf
(
"pin %s #%d @%s"
,
foid
,
blk
,
rev
))
if
err
!=
nil
{
...
...
@@ -1272,7 +1275,9 @@ func (w *Watch) pin(ctx context.Context, blk int64, rev zodb.Tid) (err error) {
return
nil
}
// setupWatch sets up a Watch when client sends `watch <file> @<at>`.
// setupWatch sets up a Watch when client sends `watch <file> @<at>` request.
//
// XXX called synchronously - only 1 setupWatch call at a time?
func
(
wlink
*
WatchLink
)
setupWatch
(
ctx
context
.
Context
,
foid
zodb
.
Oid
,
at
zodb
.
Tid
)
(
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"setup watch f<%s> @%s"
,
foid
,
at
)
// XXX locking
...
...
@@ -1294,6 +1299,22 @@ func (wlink *WatchLink) setupWatch(ctx context.Context, foid zodb.Oid, at zodb.T
}
// XXX wait wlink.head.zconn.At() ≥ at
// XXX <~> f.δtail.Head() ≥ at (?)
// XXX locking
if
f
.
δtail
.
Tail
()
<
at
{
return
fmt
.
Errorf
(
"at is too far away back from head/at"
)
}
toPin
:=
SetI64
{}
// f's blocks that have been changed after at
// XXX f.δtail.Head() not neccessarily = head.At()
// (if f was not changed by a txn, f.δtail stays not updated) XXX correct?
f
.
δtail
.
SliceByRev
(
at
,
f
.
δtail
.
Head
())
panic
(
"TODO"
)
}
...
...
@@ -1609,7 +1630,7 @@ func (head *Head) bigopen(ctx context.Context, oid zodb.Oid) (_ *BigFile, err er
rev
:
rev
,
// XXX this is needed only for head/
δ
Ftail
:
NewΔTailI64
(
zconn
.
At
()),
δ
tail
:
NewΔTailI64
(
zconn
.
At
()),
loading
:
make
(
map
[
int64
]
*
blkLoadState
),
}
...
...
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