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
d9cfa3c0
Commit
d9cfa3c0
authored
Apr 19, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X Move xbufio out of fs1
parent
0c867eca
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
28 deletions
+25
-28
t/neo/storage/fs1/cmd/fstail/fstail.go
t/neo/storage/fs1/cmd/fstail/fstail.go
+2
-1
t/neo/storage/fs1/filestorage.go
t/neo/storage/fs1/filestorage.go
+4
-3
t/neo/xcommon/xbufio/xbufio.go
t/neo/xcommon/xbufio/xbufio.go
+13
-16
t/neo/xcommon/xbufio/xbufio_test.go
t/neo/xcommon/xbufio/xbufio_test.go
+6
-8
No files found.
t/neo/storage/fs1/cmd/fstail/fstail.go
View file @
d9cfa3c0
...
...
@@ -31,6 +31,7 @@ import (
"../../../../storage/fs1"
"../../../../xcommon/xbufio"
"../../../../xcommon/xfmt"
"../../../../xcommon/xslice"
)
...
...
@@ -70,7 +71,7 @@ func fsTail(w io.Writer, path string, ntxn int) (err error) {
data
:=
[]
byte
{}
// use sequential IO buffer
fSeq
:=
fs1
.
NewSeqBufReader
(
f
)
fSeq
:=
xbufio
.
NewSeqReaderAt
(
f
)
// start iterating at tail.
// this should get EOF but read txnh.LenPrev ok.
...
...
t/neo/storage/fs1/filestorage.go
View file @
d9cfa3c0
...
...
@@ -23,6 +23,7 @@ import (
"os"
"../../zodb"
"../../xcommon/xbufio"
"../../xcommon/xslice"
)
...
...
@@ -797,7 +798,7 @@ const (
// txnIter is iterator over transaction records
type
txnIter
struct
{
fsSeq
*
SeqBufReader
fsSeq
*
xbufio
.
SeqReaderAt
Txnh
TxnHeader
// current transaction information
TidStop
zodb
.
Tid
// iterate up to tid <= tidStop | tid >= tidStop depending on .dir
...
...
@@ -807,7 +808,7 @@ type txnIter struct {
// dataIter is iterator over data records inside one transaction
type
dataIter
struct
{
fsSeq
*
SeqBufReader
fsSeq
*
xbufio
.
SeqReaderAt
Txnh
*
TxnHeader
// header of transaction we are iterating inside
Datah
DataHeader
...
...
@@ -921,7 +922,7 @@ func (fs *FileStorage) Iterate(tidMin, tidMax zodb.Tid) zodb.IStorageIterator {
Iter
:=
iterator
{}
// when iterating use IO optimized for sequential access
fsSeq
:=
NewSeqBufReader
(
fs
.
file
)
fsSeq
:=
xbufio
.
NewSeqReaderAt
(
fs
.
file
)
Iter
.
txnIter
.
fsSeq
=
fsSeq
Iter
.
dataIter
.
fsSeq
=
fsSeq
Iter
.
dataIter
.
Txnh
=
&
Iter
.
txnIter
.
Txnh
...
...
t/neo/
storage/fs1
/xbufio.go
→
t/neo/
xcommon/xbufio
/xbufio.go
View file @
d9cfa3c0
// Copyright (C) 2017 Nexedi SA and Contributors.
// Copyright (C) 2017 Nexedi SA and Contributors.
XXX -> GPLv3
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
...
...
@@ -10,9 +10,8 @@
//
// See COPYING file for full licensing terms.
// XXX move -> xbufio
package
fs1
// Package xbufio provides addons to std bufio package.
package
xbufio
import
(
"io"
...
...
@@ -20,16 +19,14 @@ import (
//"log"
)
// Seq
BufReader
implements buffering for a io.ReaderAt optimized for sequential access
// Seq
ReaderAt
implements buffering for a io.ReaderAt optimized for sequential access
// Both forward, backward and interleaved forward/backward access patterns are supported
//
// NOTE Seq
BufReader
is not safe to use from multiple goroutines concurrently.
// NOTE Seq
ReaderAt
is not safe to use from multiple goroutines concurrently.
// Strictly speaking this goes against io.ReaderAt interface but sequential
// workloads usually mean
s
sequential processing. It would be a pity to
// workloads usually mean sequential processing. It would be a pity to
// add mutex for nothing.
//
// XXX -> xbufio.SeqReader
type
SeqBufReader
struct
{
type
SeqReaderAt
struct
{
// buffer for data at pos. cap(buf) - whole buffer capacity
buf
[]
byte
pos
int64
...
...
@@ -47,12 +44,12 @@ type SeqBufReader struct {
// TODO text about syscall / memcpy etc
const
defaultSeqBufSize
=
8192
// XXX retune - must be <= size(L1d) / 2
func
NewSeq
BufReader
(
r
io
.
ReaderAt
)
*
SeqBufReader
{
return
NewSeq
BufReader
Size
(
r
,
defaultSeqBufSize
)
func
NewSeq
ReaderAt
(
r
io
.
ReaderAt
)
*
SeqReaderAt
{
return
NewSeq
ReaderAt
Size
(
r
,
defaultSeqBufSize
)
}
func
NewSeq
BufReaderSize
(
r
io
.
ReaderAt
,
size
int
)
*
SeqBufReader
{
sb
:=
&
Seq
BufReader
{
r
:
r
,
buf
:
make
([]
byte
,
0
,
size
)}
// all positions are zero initially
func
NewSeq
ReaderAtSize
(
r
io
.
ReaderAt
,
size
int
)
*
SeqReaderAt
{
sb
:=
&
Seq
ReaderAt
{
r
:
r
,
buf
:
make
([]
byte
,
0
,
size
)}
// all positions are zero initially
return
sb
}
...
...
@@ -63,7 +60,7 @@ func NewSeqBufReaderSize(r io.ReaderAt, size int) *SeqBufReader {
// }
// debug helper for sb.r.ReadAt
func
(
sb
*
Seq
BufReader
)
ioReadAt
(
p
[]
byte
,
pos
int64
)
(
int
,
error
)
{
func
(
sb
*
Seq
ReaderAt
)
ioReadAt
(
p
[]
byte
,
pos
int64
)
(
int
,
error
)
{
/*
verb := "read"
if len(p) > cap(sb.buf) {
...
...
@@ -75,7 +72,7 @@ func (sb *SeqBufReader) ioReadAt(p []byte, pos int64) (int, error) {
return
sb
.
r
.
ReadAt
(
p
,
pos
)
}
func
(
sb
*
Seq
BufReader
)
ReadAt
(
p
[]
byte
,
pos
int64
)
(
int
,
error
)
{
func
(
sb
*
Seq
ReaderAt
)
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
...
...
t/neo/
storage/fs1
/xbufio_test.go
→
t/neo/
xcommon/xbufio
/xbufio_test.go
View file @
d9cfa3c0
// Copyright (C) 2017 Nexedi SA and Contributors.
// Copyright (C) 2017 Nexedi SA and Contributors.
XXX -> GPLv3
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
...
...
@@ -10,9 +10,7 @@
//
// See COPYING file for full licensing terms.
// XXX move -> xbufio
package
fs1
package
xbufio
import
(
"bytes"
...
...
@@ -209,9 +207,9 @@ var xSeqBufTestv = []struct {pos int64; Len int; bufPos int64; bufLen int} {
}
func
TestSeq
BufReader
(
t
*
testing
.
T
)
{
func
TestSeq
ReaderAt
(
t
*
testing
.
T
)
{
r
:=
&
XReader
{}
rb
:=
NewSeq
BufReader
Size
(
r
,
10
)
// with 10 it is easier to do/check math for a human
rb
:=
NewSeq
ReaderAt
Size
(
r
,
10
)
// with 10 it is easier to do/check math for a human
for
_
,
tt
:=
range
xSeqBufTestv
{
pOk
:=
make
([]
byte
,
tt
.
Len
)
...
...
@@ -236,9 +234,9 @@ func TestSeqBufReader(t *testing.T) {
}
// this is benchmark for how thin wrapper is, not for logic inside it
func
BenchmarkSeq
BufReader
(
b
*
testing
.
B
)
{
func
BenchmarkSeq
ReaderAt
(
b
*
testing
.
B
)
{
r
:=
&
XReader
{}
rb
:=
NewSeq
BufReaderSize
(
r
,
10
)
// same as in TestSeqBufReader
rb
:=
NewSeq
ReaderAtSize
(
r
,
10
)
// same as in TestSeqReaderAt
buf
:=
make
([]
byte
,
128
/* > all .Len in xSeqBufTestv */
)
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
...
...
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