Commit 2ebe0d64 authored by Kirill Smelkov's avatar Kirill Smelkov

X use SeqBufReader when iterating - syscalls are gone from z/rust/fsiter profile

parent 06a97e5d
...@@ -812,7 +812,7 @@ const ( ...@@ -812,7 +812,7 @@ const (
// txnIter is iterator over transaction records // txnIter is iterator over transaction records
type txnIter struct { type txnIter struct {
fs *FileStorage fsSeq *SeqBufReader
Txnh TxnHeader // current transaction information Txnh TxnHeader // current transaction information
TidStop zodb.Tid // iterate up to tid <= tidStop | tid >= tidStop depending on .dir TidStop zodb.Tid // iterate up to tid <= tidStop | tid >= tidStop depending on .dir
...@@ -822,7 +822,7 @@ type txnIter struct { ...@@ -822,7 +822,7 @@ type txnIter struct {
// dataIter is iterator over data records inside one transaction // dataIter is iterator over data records inside one transaction
type dataIter struct { type dataIter struct {
fs *FileStorage fsSeq *SeqBufReader
Txnh *TxnHeader // header of transaction we are iterating inside Txnh *TxnHeader // header of transaction we are iterating inside
Datah DataHeader Datah DataHeader
...@@ -852,9 +852,9 @@ func (ti *txnIter) NextTxn(flags TxnLoadFlags) error { ...@@ -852,9 +852,9 @@ func (ti *txnIter) NextTxn(flags TxnLoadFlags) error {
default: default:
var err error var err error
if ti.Flags & iterDir != 0 { if ti.Flags & iterDir != 0 {
err = ti.Txnh.LoadNext(ti.fs.file, flags) err = ti.Txnh.LoadNext(ti.fsSeq, flags)
} else { } else {
err = ti.Txnh.LoadPrev(ti.fs.file, flags) err = ti.Txnh.LoadPrev(ti.fsSeq, flags)
} }
// XXX EOF ^^^ is not expected (range pre-cut to valid tids) ? // XXX EOF ^^^ is not expected (range pre-cut to valid tids) ?
...@@ -877,7 +877,7 @@ func (ti *txnIter) NextTxn(flags TxnLoadFlags) error { ...@@ -877,7 +877,7 @@ func (ti *txnIter) NextTxn(flags TxnLoadFlags) error {
} }
func (di *dataIter) NextData() (*zodb.StorageRecordInformation, error) { func (di *dataIter) NextData() (*zodb.StorageRecordInformation, error) {
err := di.Datah.LoadNext(di.fs.file, di.Txnh) err := di.Datah.LoadNext(di.fsSeq, di.Txnh)
if err != nil { if err != nil {
return nil, err // XXX recheck return nil, err // XXX recheck
} }
...@@ -887,7 +887,7 @@ func (di *dataIter) NextData() (*zodb.StorageRecordInformation, error) { ...@@ -887,7 +887,7 @@ func (di *dataIter) NextData() (*zodb.StorageRecordInformation, error) {
dh := di.Datah dh := di.Datah
di.sri.Data = di.dataBuf di.sri.Data = di.dataBuf
err = dh.LoadData(di.fs.file, &di.sri.Data) err = dh.LoadData(di.fsSeq, &di.sri.Data)
if err != nil { if err != nil {
return nil, err // XXX recheck return nil, err // XXX recheck
} }
...@@ -927,8 +927,11 @@ func (fs *FileStorage) Iterate(tidMin, tidMax zodb.Tid) zodb.IStorageIterator { ...@@ -927,8 +927,11 @@ func (fs *FileStorage) Iterate(tidMin, tidMax zodb.Tid) zodb.IStorageIterator {
// XXX naming // XXX naming
Iter := iterator{} Iter := iterator{}
Iter.txnIter.fs = fs
Iter.dataIter.fs = fs // when iterating use IO optimized for sequential access
fsSeq := NewSeqBufReader(fs.file)
Iter.txnIter.fsSeq = fsSeq
Iter.dataIter.fsSeq = fsSeq
Iter.dataIter.Txnh = &Iter.txnIter.Txnh Iter.dataIter.Txnh = &Iter.txnIter.Txnh
if tidMin > tidMax { if tidMin > tidMax {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment