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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Joshua
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
Hide 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:
t
.
_wcsync
()
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.
def
_wcsync
(
t
):
while
len
(
t
.
_wc_zheadv
)
<
len
(
t
.
dFtail
):
...
...
@@ -291,6 +285,13 @@ class tDB:
# head/at = last txn of whole db
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.
# - str: wcfs root + obj;
...
...
@@ -323,8 +324,7 @@ class tDB:
# iter_revv iterates through all possible at_i -> at_j -> at_k ... sequences.
# at_i < at_j
# NOTE all sequences go till head.
# at_i < at_j NOTE all sequences go till head.
def
iter_revv
(
t
,
start
=
z64
,
level
=
0
):
dFtail
=
[
_
for
_
in
t
.
dFtail
if
_
.
rev
>
start
]
#print(' '*level, 'iter_revv', t.hat(start), [t.hat(_.rev) for _ in dFtail])
...
...
@@ -340,7 +340,7 @@ class tDB:
# _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?
def
_blkData
(
t
,
zf
,
blk
,
at
):
# -> (data, rev)
if
at
is
None
:
...
...
@@ -412,9 +412,10 @@ class tFile:
# stay in pagecache.
#
# 2. madvise memory with MADV_SEQUENTIAL and MADV_RANDOM in interleaved
# mode. This adjusts kernel readahead (which triggers for MADV_SEQUENTIAL
# vma) to not go over to next block and thus a read access to one
# block won't trigger implicit read access to its neighbour block.
# mode. This adjusts kernel readahead (which triggers for
# MADV_NORMAL or MADV_SEQUENTIAL vma) to not go over to next 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://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:
# helps to test how wcfs handles simultaneous read triggered by
# async kernel readahead vs wcfs uploading data for the same block
# into OS cache. Also, fully enabled readahead is how wcfs is
# actually used.
# actually used
in practice
.
assert
t
.
blksize
%
mm
.
PAGE_SIZE
==
0
t
.
fmmap
=
mm
.
map_ro
(
t
.
f
.
fileno
(),
0
,
t
.
_max_tracked_pages
*
t
.
blksize
)
...
...
@@ -462,6 +463,7 @@ class tFile:
t
.
f
.
close
()
# _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
):
assert
blk
<=
t
.
_max_tracked_pages
return
memoryview
(
t
.
fmmap
[
blk
*
t
.
blksize
:(
blk
+
1
)
*
t
.
blksize
])
...
...
@@ -491,7 +493,7 @@ class tFile:
assert
st
.
st_size
//
t
.
blksize
<=
t
.
_max_tracked_pages
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.
def
assertCache
(
t
,
incorev
):
...
...
@@ -537,14 +539,14 @@ class tFile:
defer
(
_
)
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
# watches that must be notified if access goes to @head/file
wpin
=
{}
# tWatchLink -> pinok
for
wlink
in
t
.
tdb
.
_wlinks
:
pinok
=
{}
if
t
.
at
is
None
:
# @head/...
if
t
.
at
is
None
:
# @head/...
for
wlink
in
t
.
tdb
.
_wlinks
:
pinok
=
{}
w
=
wlink
.
_watching
.
get
(
t
.
zf
)
if
w
is
not
None
and
w
.
at
<
blkrev
:
if
cached
==
1
:
...
...
@@ -558,7 +560,7 @@ class tFile:
if
blk
not
in
w
.
pinned
:
pinok
=
{
blk
:
t
.
tdb
.
_blkRev
(
t
.
zf
,
blk
,
w
.
at
)}
shouldPin
=
True
wpin
[
wlink
]
=
pinok
wpin
[
wlink
]
=
pinok
if
pinokByWLink
is
not
None
:
assert
wpin
==
pinokByWLink
,
"computed vs explicit pinokByWLink"
...
...
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