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
e563a4e3
Commit
e563a4e3
authored
Jun 19, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
1146656d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
19 deletions
+21
-19
wcfs/wcfs_test.py
wcfs/wcfs_test.py
+21
-19
No files found.
wcfs/wcfs_test.py
View file @
e563a4e3
...
@@ -270,12 +270,6 @@ class tDB:
...
@@ -270,12 +270,6 @@ class tDB:
t
.
_wcsync
()
t
.
_wcsync
()
return
head
return
head
# _blkaccess marks head/zf[blk] accessed.
def
_blkaccess
(
t
,
zf
,
blk
):
# XXX locking
zfAccessed
=
t
.
_accessed
.
setdefault
(
zf
,
{})
zfAccessed
[
blk
]
=
t
.
head
# _wcsync makes sure wcfs is synchronized to latest committed transaction.
# _wcsync makes sure wcfs is synchronized to latest committed transaction.
def
_wcsync
(
t
):
def
_wcsync
(
t
):
while
len
(
t
.
_wc_zheadv
)
<
len
(
t
.
dFtail
):
while
len
(
t
.
_wc_zheadv
)
<
len
(
t
.
dFtail
):
...
@@ -291,6 +285,13 @@ class tDB:
...
@@ -291,6 +285,13 @@ class tDB:
# head/at = last txn of whole db
# head/at = last txn of whole db
assert
t
.
read
(
"head/at"
)
==
h
(
t
.
head
)
assert
t
.
read
(
"head/at"
)
==
h
(
t
.
head
)
# _blkaccess marks head/zf[blk] accessed.
# XXX place=?
def
_blkaccess
(
t
,
zf
,
blk
):
# XXX locking?
zfAccessed
=
t
.
_accessed
.
setdefault
(
zf
,
{})
zfAccessed
[
blk
]
=
t
.
head
# path returns path for object on wcfs.
# path returns path for object on wcfs.
# - str: wcfs root + obj;
# - str: wcfs root + obj;
...
@@ -323,8 +324,7 @@ class tDB:
...
@@ -323,8 +324,7 @@ class tDB:
# iter_revv iterates through all possible at_i -> at_j -> at_k ... sequences.
# iter_revv iterates through all possible at_i -> at_j -> at_k ... sequences.
# at_i < at_j
# at_i < at_j NOTE all sequences go till head.
# NOTE all sequences go till head.
def
iter_revv
(
t
,
start
=
z64
,
level
=
0
):
def
iter_revv
(
t
,
start
=
z64
,
level
=
0
):
dFtail
=
[
_
for
_
in
t
.
dFtail
if
_
.
rev
>
start
]
dFtail
=
[
_
for
_
in
t
.
dFtail
if
_
.
rev
>
start
]
#print(' '*level, 'iter_revv', t.hat(start), [t.hat(_.rev) for _ in dFtail])
#print(' '*level, 'iter_revv', t.hat(start), [t.hat(_.rev) for _ in dFtail])
...
@@ -340,7 +340,7 @@ class tDB:
...
@@ -340,7 +340,7 @@ class tDB:
# _blkData returns expected zf[blk] data and revision as of @at database state.
# _blkData returns expected zf[blk] data and revision as of @at database state.
#
#
# If the block is hole (b'', at0) is returned. XXX -> @z64?
# If the block is hole
-
(b'', at0) is returned. XXX -> @z64?
# XXX ret for when the file did not existed at all? blk was after file size?
# XXX ret for when the file did not existed at all? blk was after file size?
def
_blkData
(
t
,
zf
,
blk
,
at
):
# -> (data, rev)
def
_blkData
(
t
,
zf
,
blk
,
at
):
# -> (data, rev)
if
at
is
None
:
if
at
is
None
:
...
@@ -412,9 +412,10 @@ class tFile:
...
@@ -412,9 +412,10 @@ class tFile:
# stay in pagecache.
# stay in pagecache.
#
#
# 2. madvise memory with MADV_SEQUENTIAL and MADV_RANDOM in interleaved
# 2. madvise memory with MADV_SEQUENTIAL and MADV_RANDOM in interleaved
# mode. This adjusts kernel readahead (which triggers for MADV_SEQUENTIAL
# mode. This adjusts kernel readahead (which triggers for
# vma) to not go over to next block and thus a read access to one
# MADV_NORMAL or MADV_SEQUENTIAL vma) to not go over to next block
# block won't trigger implicit read access to its neighbour block.
# and thus a read access to one block won't trigger implicit read
# access to its neighbour block.
#
#
# https://www.quora.com/What-heuristics-does-the-adaptive-readahead-implementation-in-the-Linux-kernel-use
# https://www.quora.com/What-heuristics-does-the-adaptive-readahead-implementation-in-the-Linux-kernel-use
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/mm/madvise.c?h=v5.2-rc4#n51
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/mm/madvise.c?h=v5.2-rc4#n51
...
@@ -427,7 +428,7 @@ class tFile:
...
@@ -427,7 +428,7 @@ class tFile:
# helps to test how wcfs handles simultaneous read triggered by
# helps to test how wcfs handles simultaneous read triggered by
# async kernel readahead vs wcfs uploading data for the same block
# async kernel readahead vs wcfs uploading data for the same block
# into OS cache. Also, fully enabled readahead is how wcfs is
# into OS cache. Also, fully enabled readahead is how wcfs is
# actually used.
# actually used
in practice
.
assert
t
.
blksize
%
mm
.
PAGE_SIZE
==
0
assert
t
.
blksize
%
mm
.
PAGE_SIZE
==
0
t
.
fmmap
=
mm
.
map_ro
(
t
.
f
.
fileno
(),
0
,
t
.
_max_tracked_pages
*
t
.
blksize
)
t
.
fmmap
=
mm
.
map_ro
(
t
.
f
.
fileno
(),
0
,
t
.
_max_tracked_pages
*
t
.
blksize
)
...
@@ -462,6 +463,7 @@ class tFile:
...
@@ -462,6 +463,7 @@ class tFile:
t
.
f
.
close
()
t
.
f
.
close
()
# _blk returns memoryview of file[blk].
# _blk returns memoryview of file[blk].
# when/if block memory is accessed, the user has to notify tDB with _blkaccess call.
def
_blk
(
t
,
blk
):
def
_blk
(
t
,
blk
):
assert
blk
<=
t
.
_max_tracked_pages
assert
blk
<=
t
.
_max_tracked_pages
return
memoryview
(
t
.
fmmap
[
blk
*
t
.
blksize
:(
blk
+
1
)
*
t
.
blksize
])
return
memoryview
(
t
.
fmmap
[
blk
*
t
.
blksize
:(
blk
+
1
)
*
t
.
blksize
])
...
@@ -491,7 +493,7 @@ class tFile:
...
@@ -491,7 +493,7 @@ class tFile:
assert
st
.
st_size
//
t
.
blksize
<=
t
.
_max_tracked_pages
assert
st
.
st_size
//
t
.
blksize
<=
t
.
_max_tracked_pages
return
st
.
st_size
//
t
.
blksize
return
st
.
st_size
//
t
.
blksize
# assertCache asserts state of OS cache for file.
# assertCache asserts
on
state of OS cache for file.
#
#
# incorev is [] of 1/0 representing whether block data is present or not.
# incorev is [] of 1/0 representing whether block data is present or not.
def
assertCache
(
t
,
incorev
):
def
assertCache
(
t
,
incorev
):
...
@@ -537,14 +539,14 @@ class tFile:
...
@@ -537,14 +539,14 @@ class tFile:
defer
(
_
)
defer
(
_
)
cached
=
t
.
cached
()[
blk
]
cached
=
t
.
cached
()[
blk
]
assert
cached
in
(
0
,
1
)
# every check access a block in full
assert
cached
in
(
0
,
1
)
# every check access
es
a block in full
shouldPin
=
False
# whether at least one wlink should receive a pin
shouldPin
=
False
# whether at least one wlink should receive a pin
# watches that must be notified if access goes to @head/file
# watches that must be notified if access goes to @head/file
wpin
=
{}
# tWatchLink -> pinok
wpin
=
{}
# tWatchLink -> pinok
if
t
.
at
is
None
:
# @head/...
for
wlink
in
t
.
tdb
.
_wlinks
:
for
wlink
in
t
.
tdb
.
_wlinks
:
pinok
=
{}
pinok
=
{}
if
t
.
at
is
None
:
# @head/...
w
=
wlink
.
_watching
.
get
(
t
.
zf
)
w
=
wlink
.
_watching
.
get
(
t
.
zf
)
if
w
is
not
None
and
w
.
at
<
blkrev
:
if
w
is
not
None
and
w
.
at
<
blkrev
:
if
cached
==
1
:
if
cached
==
1
:
...
...
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