Commit c1abf2c6 authored by Kirill Smelkov's avatar Kirill Smelkov

X use SeqBufReader in fstail

only -9%

name       old time/op  new time/op  delta
Iterate-4  17.4µs ± 0%  17.5µs ± 0%    ~     (p=0.234 n=10+9)
FsTail-4    278µs ± 1%   252µs ± 0%  -9.12%  (p=0.000 n=10+10)

because there are many IO direction misses.
parent e7fb63c5
......@@ -128,12 +128,12 @@ func fsTail(w io.Writer, path string, ntxn int) (err error) {
txnh := fs1.TxnHeader{}
data := []byte{}
// TODO use SeqBufReader instead of f and check speedup
// use sequential IO buffer
fSeq := fs1.NewSeqBufReader(f)
// start iterating at tail.
// this should get EOF but read txnh.LenPrev ok.
err = txnh.Load(f, topPos, fs1.LoadAll)
err = txnh.Load(fSeq, topPos, fs1.LoadAll)
if err != io.EOF {
if err == nil {
// XXX or allow this?
......@@ -150,7 +150,7 @@ func fsTail(w io.Writer, path string, ntxn int) (err error) {
// now loop loading transactions backwards until EOF / ntxn limit
for i := ntxn; i > 0; i-- {
err = txnh.LoadPrev(f, fs1.LoadAll)
err = txnh.LoadPrev(fSeq, fs1.LoadAll)
if err != nil {
if err == io.EOF {
err = nil // XXX -> okEOF(err)
......@@ -166,7 +166,7 @@ func fsTail(w io.Writer, path string, ntxn int) (err error) {
data = data[:dataLen]
}
_, err = f.ReadAt(data, txnh.DataPos())
_, err = fSeq.ReadAt(data, txnh.DataPos())
if err != nil {
// XXX -> txnh.Err(...) ?
// XXX err = noEOF(err)
......
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