Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flush vlog buffer if it grows beyond threshold #1067

Merged
merged 4 commits into from
Oct 10, 2019
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions value.go
Original file line number Diff line number Diff line change
Expand Up @@ -1315,6 +1315,18 @@ func (vlog *valueLog) write(reqs []*request) error {
p.Len = uint32(plen)
b.Ptrs = append(b.Ptrs, p)
written++

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the buffer length be stored since it is retrieved multiple times?

bl := buf.Len()

if int64(buf.Len()) > vlog.db.opt.ValueLogFileSize {
vlog.elog.Printf("Flushing buffer of size %d to vlog", buf.Len())
n, err := curlf.fd.Write(buf.Bytes())
if err != nil {
return errors.Wrapf(err, "Unable to write to value log file: %q", curlf.path)
}
buf.Reset()
y.NumWrites.Add(1)
y.NumBytesWritten.Add(int64(n))
atomic.AddUint32(&vlog.writableLogOffset, uint32(n))
}
}
vlog.numEntriesWritten += uint32(written)
// We write to disk here so that all entries that are part of the same transaction are
Expand Down