-
Notifications
You must be signed in to change notification settings - Fork 95
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
Commit pipeline when write a WriteBatch for linearizability #267
Conversation
464bd28
to
18157cc
Compare
/test |
See benchmark result in https://docs.google.com/document/d/1s5Dj02hhe18zzwKTUZF4n1Bi0z6p5_d9TfoMkHKm2XE/edit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should check writer.status.ok()
assert(writer.state == WriteThread::STATE_COMPLETED); | ||
TEST_SYNC_POINT("DBImpl::WriteImpl:CommitAfterWriteWAL"); | ||
|
||
if (writer.request->commit_lsn != 0 && writer.status.ok()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about writing like this, it's clearer
if (write.request -> commit_lsn == 0) {
//
} else if (write.status.ok()) {
//
} else {
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think so....
db/write_thread.h
Outdated
|
||
private: | ||
std::mutex commit_mu_; | ||
std::condition_variable cv_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use InstrumentedCondVar
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems heavily...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use port::Mutex and port::CondVar. Honestly I don't know why the old code uses std::mutex
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change the base branch to 6.4.tikv
, rest LGTM
Signed-off-by: Little-Wallace <bupt2013211450@gmail.com>
336f6ab
to
527b170
Compare
Signed-off-by: Little-Wallace <bupt2013211450@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rest looks good.
WriteThread::WriteGroup wal_write_group; | ||
mutex_.Lock(); | ||
if (writer.callback && !writer.callback->AllowWriteBatching()) { | ||
WaitForPendingWrites(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why different than before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because we need to make sure that all memtable writes are applied before we checkcallback so that we can see a consistent result from DB
Signed-off-by: Little-Wallace <bupt2013211450@gmail.com>
/test |
* support commit pipeline Signed-off-by: Little-Wallace <bupt2013211450@gmail.com> Signed-off-by: tabokie <xy.tao@outlook.com>
* add multibatch write into memtable (#131) Signed-off-by: Little-Wallace <bupt2013211450@gmail.com> Support write multiple WriteBatch into RocksDB together. These WriteBatch will be assigned sequence number in order and pushed into queue. If a thread is waiting for some state, it could steal some job from work queue. Signed-off-by: tabokie <xy.tao@outlook.com> * Improve Multi Batch Write (#154) * perform like normal pipelined write Signed-off-by: Little-Wallace <bupt2013211450@gmail.com> Signed-off-by: tabokie <xy.tao@outlook.com> * pass enable_multi_thread_write to BuildDBOptions (#170) Signed-off-by: Little-Wallace <bupt2013211450@gmail.com> Signed-off-by: tabokie <xy.tao@outlook.com> * Fix life time of `memtable_write_group` (#171) * fix life time of memtable_write_group Signed-off-by: Little-Wallace <bupt2013211450@gmail.com> Signed-off-by: tabokie <xy.tao@outlook.com> * Commit pipeline when write a WriteBatch for linearizability (#267) * support commit pipeline Signed-off-by: Little-Wallace <bupt2013211450@gmail.com> Signed-off-by: tabokie <xy.tao@outlook.com> * format Signed-off-by: tabokie <xy.tao@outlook.com> * remove useless code Signed-off-by: tabokie <xy.tao@outlook.com> Co-authored-by: Wallace <bupt2013211450@gmail.com>
* add multibatch write into memtable (#131) Signed-off-by: Little-Wallace <bupt2013211450@gmail.com> Support write multiple WriteBatch into RocksDB together. These WriteBatch will be assigned sequence number in order and pushed into queue. If a thread is waiting for some state, it could steal some job from work queue. Signed-off-by: tabokie <xy.tao@outlook.com> * Improve Multi Batch Write (#154) * perform like normal pipelined write Signed-off-by: Little-Wallace <bupt2013211450@gmail.com> Signed-off-by: tabokie <xy.tao@outlook.com> * pass enable_multi_thread_write to BuildDBOptions (#170) Signed-off-by: Little-Wallace <bupt2013211450@gmail.com> Signed-off-by: tabokie <xy.tao@outlook.com> * Fix life time of `memtable_write_group` (#171) * fix life time of memtable_write_group Signed-off-by: Little-Wallace <bupt2013211450@gmail.com> Signed-off-by: tabokie <xy.tao@outlook.com> * Commit pipeline when write a WriteBatch for linearizability (#267) * support commit pipeline Signed-off-by: Little-Wallace <bupt2013211450@gmail.com> Signed-off-by: tabokie <xy.tao@outlook.com> * format Signed-off-by: tabokie <xy.tao@outlook.com> * remove useless code Signed-off-by: tabokie <xy.tao@outlook.com> Co-authored-by: Wallace <bupt2013211450@gmail.com>
This method is proposed by pebble
I support async method so that the write thread does not need wait this writebatch committed.