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
043ddf93
Commit
043ddf93
authored
Apr 04, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
64199d5f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
54 deletions
+8
-54
t/neo/storage/fs1/xbufio.go
t/neo/storage/fs1/xbufio.go
+8
-54
No files found.
t/neo/storage/fs1/xbufio.go
View file @
043ddf93
...
...
@@ -7,7 +7,7 @@ package fs1
import
(
"io"
"log"
//
"log"
)
// SeqBufReader implements buffering for a io.ReaderAt optimized for sequential access
...
...
@@ -38,10 +38,10 @@ func NewSeqBufReaderSize(r io.ReaderAt, size int) *SeqBufReader {
}
// XXX temp
func
init
()
{
log
.
SetFlags
(
0
)
}
//
//
XXX temp
//
func init() {
//
log.SetFlags(0)
//
}
func
(
sb
*
SeqBufReader
)
ReadAt
(
p
[]
byte
,
pos
int64
)
(
int
,
error
)
{
// if request size > buffer - read data directly
...
...
@@ -49,7 +49,7 @@ func (sb *SeqBufReader) ReadAt(p []byte, pos int64) (int, error) {
// no copying from sb.buf here at all as if e.g. we could copy from sb.buf, the
// kernel can copy the same data from pagecache as well, and it will take the same time
// because for data in sb.buf corresponding page in pagecache has high p. to be hot.
log
.
Printf
(
"READ [%v, %v)
\t
#%v"
,
pos
,
pos
+
len64
(
p
),
len
(
p
))
//
log.Printf("READ [%v, %v)\t#%v", pos, pos + len64(p), len(p))
sb
.
posLastIO
=
pos
return
sb
.
r
.
ReadAt
(
p
,
pos
)
}
...
...
@@ -125,7 +125,7 @@ func (sb *SeqBufReader) ReadAt(p []byte, pos int64) (int, error) {
xpos
=
max64
(
xpos
,
0
)
}
log
.
Printf
(
"read [%v, %v)
\t
#%v"
,
xpos
,
xpos
+
cap64
(
sb
.
buf
),
cap
(
sb
.
buf
))
//
log.Printf("read [%v, %v)\t#%v", xpos, xpos + cap64(sb.buf), cap(sb.buf))
sb
.
posLastIO
=
xpos
nn
,
err
:=
sb
.
r
.
ReadAt
(
sb
.
buf
[
:
cap
(
sb
.
buf
)],
xpos
)
...
...
@@ -148,7 +148,7 @@ func (sb *SeqBufReader) ReadAt(p []byte, pos int64) (int, error) {
// - 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
))
//
log.Printf("read [%v, %v)\t#%v", pos, pos + len64(p), len(p))
sb
.
posLastIO
=
pos
nn
,
err
=
sb
.
r
.
ReadAt
(
p
,
pos
)
if
nn
<
len
(
p
)
{
...
...
@@ -170,52 +170,6 @@ func (sb *SeqBufReader) ReadAt(p []byte, pos int64) (int, error) {
// NOTE if there was an error - we can skip it if original read request was completely satisfied
// NOTE not preserving EOF at ends - not required per ReaderAt interface
return
nhead
+
nn
+
ntail
,
nil
/*
// here we know:
// - some data was read
// - len(p) <= cap(sb.buf)
// - there is overlap in between pos/p vs sb.pos/sb.buf
// try to read again what is left to read from the buffer
// nn, p, pos = sb.readFromBuf(p, pos)
// ---- 8< ---- (inlined readFromBuf)
// use buffered data: start + forward
if sb.pos <= pos && pos < sb.pos + int64(len(sb.buf)) {
nn = copy(p, sb.buf[pos - sb.pos:]) // NOTE len(p) can be < len(sb[copyPos:])
p = p[nn:]
pos += int64(nn)
// use buffered data: tail + backward
} else if posAfter := pos + int64(len(p));
len(p) != 0 &&
sb.pos < posAfter && posAfter <= sb.pos + int64(len(sb.buf)) {
// here we know pos < sb.pos
//
// proof: consider if pos >= sb.pos.
// Then from `pos <= sb.pos + len(sb.buf) - len(p)` above it follow that:
// `pos < sb.pos + len(sb.buf)` (NOTE strictly < because if len(p) > 0)
// and we come to condition which is used in `start + forward` if
nn = copy(p[sb.pos - pos:], sb.buf) // NOTE nn == len(p[sb.pos - pos:])
p = p[:sb.pos - pos]
// pos for actual read stays the same
}
// ---- 8< ----
n += nn
// if there was an error - we can skip it if original read request was
// completely satisfied
if len(p) == 0 {
// NOTE not preserving EOF at ends - not needed per ReaderAt
// interface.
err = nil
}
// all done
return n, err
*/
}
...
...
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