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

add multibatch write into memtable #131

Merged
merged 8 commits into from
Jan 7, 2020

Conversation

Little-Wallace
Copy link

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: Little-Wallace <bupt2013211450@gmail.com>
Signed-off-by: Little-Wallace <bupt2013211450@gmail.com>
Signed-off-by: Little-Wallace <bupt2013211450@gmail.com>
@Little-Wallace Little-Wallace changed the base branch from 6.4.tikv to 6.4.tikv-poc November 27, 2019 05:36
@Little-Wallace Little-Wallace changed the base branch from 6.4.tikv-poc to 6.4.tikv November 27, 2019 05:36
@yiwu-arbug yiwu-arbug self-requested a review December 18, 2019 04:43
Copy link
Collaborator

@yiwu-arbug yiwu-arbug left a comment

Choose a reason for hiding this comment

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

Sorry for the super long delay in reviewing.

I did a quick comparison between PipelinedWriteImpl and MultiThreadWriteImpl and find some difference. Also some minor comment about memory ordering for atomic variables. I'll do another pass tomorrow.

util/safe_queue.h Outdated Show resolved Hide resolved
@@ -550,6 +550,13 @@ Options DBTestBase::GetOptions(
options.enable_pipelined_write = true;
break;
}
case kMultiThreadWrite: {
if (options.allow_concurrent_memtable_write) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

should this be enable_multi_thread_write = true regardless of allow_concurrent_memtable_write value?

Copy link
Author

Choose a reason for hiding this comment

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

I can not understand. allow_concurrent_memtable_write is necessary so that we can insert into skiplist concurrently.

Copy link
Collaborator

Choose a reason for hiding this comment

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

But DBImpl::SanitizeOptions is setting allow_concurrent_memtable_write=true when enable_multi_thread_write=true is set.

Copy link
Author

Choose a reason for hiding this comment

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

Ok. I will remove it.

db/db_impl/db_impl_write.cc Outdated Show resolved Hide resolved
db/db_impl/db_impl_write.cc Outdated Show resolved Hide resolved
@@ -114,6 +117,7 @@ class WriteThread {
// Information kept for every waiting writer.
struct Writer {
WriteBatch* batch;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it easy to remove batch in favor of batches?

Copy link
Author

Choose a reason for hiding this comment

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

Not easy....

db/db_impl/db_impl_write.cc Show resolved Hide resolved
db/db_impl/db_impl_write.cc Outdated Show resolved Hide resolved
while (memtable_write_group.running.load(std::memory_order_acquire) > 0) {
std::function<void()> work;
if (write_thread_.write_queue_.PopFront(work)) {
work();
Copy link
Collaborator

Choose a reason for hiding this comment

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

here the leader works on the writer queue. how does followers help with the work?

Copy link
Author

Choose a reason for hiding this comment

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

Followers would do this work in AwaitState.

db/db_impl/db_impl_write.cc Show resolved Hide resolved
db/write_batch.cc Outdated Show resolved Hide resolved
@@ -137,6 +141,43 @@ uint8_t WriteThread::AwaitState(Writer* w, uint8_t goal_mask,
// 1/sampling_base.
const int sampling_base = 256;

if (enable_multi_thread_write_) {
#ifdef NDEBUG
Copy link
Collaborator

Choose a reason for hiding this comment

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

what's the reason debug build and release build logic are different?

Copy link
Author

Choose a reason for hiding this comment

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

Because unit test need to block and wait SYNC_POINT to wake up. But in product environment, we need it not block thread so that it could do more jobs.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Would be great if release build and debug build can use the same logic. Otherwise rocksdb unit tests (maybe also tikv unit tests and schrodinger tests?) is not testing the real logic.

db/write_batch.cc Outdated Show resolved Hide resolved
Copy link
Collaborator

@yiwu-arbug yiwu-arbug left a comment

Choose a reason for hiding this comment

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

LGTM overall.

Signed-off-by: Little-Wallace <bupt2013211450@gmail.com>
Signed-off-by: Little-Wallace <bupt2013211450@gmail.com>
Signed-off-by: Little-Wallace <bupt2013211450@gmail.com>
Signed-off-by: Little-Wallace <bupt2013211450@gmail.com>
@Little-Wallace
Copy link
Author

/run-all-tests

Copy link
Collaborator

@yiwu-arbug yiwu-arbug left a comment

Choose a reason for hiding this comment

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

LGTM. Please fix CI.

@Little-Wallace
Copy link
Author

/run-all-tests

@yiwu-arbug yiwu-arbug merged commit ebec1bd into tikv:6.4.tikv Jan 7, 2020
@Little-Wallace Little-Wallace deleted the multibatch branch December 24, 2021 06:22
@tabokie tabokie mentioned this pull request May 9, 2022
39 tasks
tabokie pushed a commit to tabokie/rocksdb that referenced this pull request May 12, 2022
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>
tabokie added a commit that referenced this pull request May 12, 2022
* 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>
tabokie added a commit that referenced this pull request May 25, 2022
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants