提交 b2274da0 编写于 作者: S Siying Dong 提交者: Facebook Github Bot

LogWriter to only flush after finish generating whole record (#5328)

Summary:
Right now, in log writer, we call flush after writing each physical record. I don't see the necessarity of it. Right now, the underlying writer has a buffer, so there isn't a concern that the write request is too large either. On the other hand, in an Env where every flush is expensive, the current approach is significantly slower than only flushing after a whole record finishes, when the record is very large.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/5328

Differential Revision: D15425032

Pulled By: siying

fbshipit-source-id: 440ebef002dfbb60c59d8388c9ddfc83d79700aa
上级 cd43446d
......@@ -13,6 +13,7 @@
* DBIter::Next() can skip user key checking if previous entry's seqnum is 0.
* Merging iterator to avoid child iterator reseek for some cases
* Reduce iterator key comparision for upper/lower bound check.
* Log Writer will flush after finishing the whole record, rather than a fragment.
### General Improvements
* Added new status code kColumnFamilyDropped to distinguish between Column Family Dropped and DB Shutdown in progress.
......
......@@ -102,6 +102,13 @@ Status Writer::AddRecord(const Slice& slice) {
left -= fragment_length;
begin = false;
} while (s.ok() && left > 0);
if (s.ok()) {
if (!manual_flush_) {
s = dest_->Flush();
}
}
return s;
}
......@@ -146,11 +153,6 @@ Status Writer::EmitPhysicalRecord(RecordType t, const char* ptr, size_t n) {
Status s = dest_->Append(Slice(buf, header_size));
if (s.ok()) {
s = dest_->Append(Slice(ptr, n));
if (s.ok()) {
if (!manual_flush_) {
s = dest_->Flush();
}
}
}
block_offset_ += header_size + n;
return s;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册