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
This commit is contained in:
Siying Dong 2019-05-21 12:17:15 -07:00 committed by Facebook Github Bot
parent cd43446d01
commit b2274da0e5
2 changed files with 8 additions and 5 deletions

View File

@ -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.

View File

@ -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;