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
7619a147
Commit
7619a147
authored
7 years ago
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
fa3317fe
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
6 deletions
+21
-6
t/neo/storage/fs1/xbufio.go
t/neo/storage/fs1/xbufio.go
+21
-6
No files found.
t/neo/storage/fs1/xbufio.go
View file @
7619a147
...
...
@@ -26,6 +26,9 @@ type SeqBufReader struct {
posLastBackward
int64
// position of last backward access request
r
io
.
ReaderAt
// debug: for ioReadAt tracing
//posLastIO int64
}
// TODO text about syscall / memcpy etc
...
...
@@ -46,7 +49,22 @@ func NewSeqBufReaderSize(r io.ReaderAt, size int) *SeqBufReader {
// log.SetFlags(0)
// }
// debug helper for sb.r.ReadAt
func
(
sb
*
SeqBufReader
)
ioReadAt
(
p
[]
byte
,
pos
int64
)
(
int
,
error
)
{
/*
verb := "read"
if len(p) > cap(sb.buf) {
verb = "READ"
}
log.Printf("%s\t[%v, %v)\t#%v\tIO%+d", verb, pos, pos + len64(p), len(p), pos - sb.posLastIO)
sb.posLastIO = pos
*/
return
sb
.
r
.
ReadAt
(
p
,
pos
)
}
func
(
sb
*
SeqBufReader
)
ReadAt
(
p
[]
byte
,
pos
int64
)
(
int
,
error
)
{
//log.Printf("access\t[%v, %v)\t#%v\t@%+d", pos, pos + len64(p), len(p), pos - sb.posLastAccess)
// read-in last access positions and update them in *sb with current ones for next read
posLastAccess
:=
sb
.
posLastAccess
posLastFwdAfter
:=
sb
.
posLastFwdAfter
...
...
@@ -63,8 +81,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))
return
sb
.
r
.
ReadAt
(
p
,
pos
)
return
sb
.
ioReadAt
(
p
,
pos
)
}
var
nhead
int
// #data read from buffer for p head
...
...
@@ -160,8 +177,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))
nn
,
err
:=
sb
.
r
.
ReadAt
(
sb
.
buf
[
:
cap
(
sb
.
buf
)],
xpos
)
nn
,
err
:=
sb
.
ioReadAt
(
sb
.
buf
[
:
cap
(
sb
.
buf
)],
xpos
)
// even if there was an error, or data partly read, we cannot retain
// the old buf content as io.ReaderAt can use whole buf as scratch space
...
...
@@ -180,8 +196,7 @@ func (sb *SeqBufReader) ReadAt(p []byte, pos int64) (int, error) {
// 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
)
nn
,
err
=
sb
.
ioReadAt
(
p
,
pos
)
if
nn
<
len
(
p
)
{
return
nhead
+
nn
,
err
}
...
...
This diff is collapsed.
Click to expand it.
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