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
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
Stefane Fermigier
neo
Commits
0a59d90a
Commit
0a59d90a
authored
Apr 05, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
ba9987d8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
8 deletions
+47
-8
t/neo/storage/fs1/xbufio.go
t/neo/storage/fs1/xbufio.go
+6
-8
t/neo/storage/fs1/xbufio_test.go
t/neo/storage/fs1/xbufio_test.go
+41
-0
No files found.
t/neo/storage/fs1/xbufio.go
View file @
0a59d90a
...
...
@@ -144,7 +144,7 @@ func (sb *SeqBufReader) ReadAt(p []byte, pos int64) (int, error) {
xpos
=
max64
(
xLastBackward
,
xpos
+
len64
(
p
))
-
cap64
(
sb
.
buf
)
// alternatively even if backward trend does not continue anymore
// but if this will overlap with last access
(XXX load)
range, probably
// but if this will overlap with last access range, probably
// it is better (we are optimizing for sequential access) to
// shift loading region down not to overlap. example:
//
...
...
@@ -177,17 +177,15 @@ func (sb *SeqBufReader) ReadAt(p []byte, pos int64) (int, error) {
if
pBufOffset
>=
len64
(
sb
.
buf
)
{
// this can be only due to some IO error
// if we know:
// - it was backward reading, and
// - original requst was narrower than buffer
// try to satisfy it once again directly
if
pos
!=
xpos
{
// FIXME pos != xpos no longer means backward
// if original requst was narrower than buffer try to satisfy
// it once again directly
if
pos
!=
xpos
{
//log.Printf("read [%v, %v)\t#%v", pos, pos + len64(p), len(p))
nn
,
err
=
sb
.
r
.
ReadAt
(
p
,
pos
)
if
nn
<
len
(
p
)
{
return
nn
,
err
return
n
head
+
n
n
,
err
}
return
nn
+
ntail
,
nil
// request fully satisfied - we can ignore error
return
n
head
+
n
n
+
ntail
,
nil
// request fully satisfied - we can ignore error
}
// Just return the error
...
...
t/neo/storage/fs1/xbufio_test.go
View file @
0a59d90a
...
...
@@ -153,10 +153,51 @@ var xSeqBufTestv = []struct {pos int64; Len int; bufPos int64; bufLen int} {
{
108
,
10
,
108
,
10
},
// reset @108
{
98
,
1
,
89
,
10
},
// backward not overlapping EIO: buf filled according to backward trend
// forward (trend) vs EIO
{
0
,
1
,
0
,
10
},
{
88
,
10
,
88
,
10
},
// reset forward @98
{
98
,
1
,
98
,
2
},
// forward not overlapping EIO: buf filled < EIO range
{
0
,
1
,
0
,
10
},
{
88
,
10
,
88
,
10
},
// reset forward @98
{
99
,
4
,
98
,
2
},
// forward overlapping head EIO: buf filled < EIO range, EIO -> user
{
0
,
1
,
0
,
10
},
{
88
,
10
,
88
,
10
},
// reset forward @98
{
99
,
6
,
98
,
2
},
// forward overlapping whole EIO range: buf filled <= EIO range, EIO -> user
{
0
,
1
,
0
,
10
},
{
88
,
10
,
88
,
10
},
// reset forward @98
{
100
,
4
,
98
,
2
},
// forward = EIO range: buf filled < EIO range, EIO -> user
{
0
,
1
,
0
,
10
},
{
90
,
10
,
90
,
10
},
// reset forward @100
{
101
,
2
,
100
,
0
},
// forward inside EIO range: buf scratched, EIO -> user
{
0
,
1
,
0
,
10
},
{
90
,
10
,
90
,
10
},
// reset forward @100
{
103
,
5
,
100
,
0
},
// forward overlapping tail EIO: buf scratched, EIO -> user
{
0
,
1
,
0
,
10
},
{
90
,
10
,
90
,
10
},
// reset forward @100
{
105
,
2
,
100
,
0
},
// forward client after EIO: buf scratched but read request satisfied
{
0
,
1
,
0
,
10
},
{
90
,
5
,
90
,
10
},
// reset forward @95
{
99
,
3
,
96
,
4
},
// forward jump client overlapping head EIO: buf filled < EIO range, EIO -> user
{
0
,
1
,
0
,
10
},
{
89
,
5
,
89
,
10
},
// reset forward @94
{
98
,
2
,
95
,
5
},
// forward jump client reading < EIO: buf filled < EIO range, user request satisfied
// EOF handling
{
250
,
4
,
250
,
6
},
// access near EOF - buffer fill hits EOF, but not returns it to client
{
254
,
5
,
256
,
0
},
// access overlapping EOF - EOF returned, buf scratched
{
256
,
1
,
256
,
0
},
// access past EOF -> EOF
{
257
,
1
,
257
,
0
},
// ----//----
// forward with jumps - buffer is still refilled adjacent to previous reading
// ( because jumps are not sequential access and we are optimizing for sequential cases.
// also: if jump > cap(buf) reading will not be adjacent)
{
0
,
1
,
0
,
10
},
// reset
{
0
,
5
,
0
,
10
},
{
9
,
3
,
6
,
10
},
{
20
,
3
,
20
,
10
},
}
...
...
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