-
Notifications
You must be signed in to change notification settings - Fork 71
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
Support Non-Blocking Manual Compactions (CompactRange) (#597) #656
Conversation
@udi-speedb please add example file how to use the new non blocking compaction feature |
please use port::Thread and not std::thread for spawning threads, so the on thread start callback will work on those threads |
Done. Please just note that I have made the ThreadWithCb::joinable() a const method (same as std::thread::joinable()) (I am calling this method from a const method of mine). |
ad48fb2
to
9a686a1
Compare
Done |
980510e
to
2c93929
Compare
@udi-speedb add a unit test for closing the db before compact range has been completed |
As we have discussed, it will be the user's responsibility to wait for all non-blocking CompactRange() calls to have their respective callbacks called. Thereafter, the Close() shouldn't have any issues joining the internal threads. |
using ValidateCompletionStatusFunc = | ||
std::function<void(ROCKSDB_NAMESPACE::Status completion_status)>; | ||
|
||
void DefaultCompletionStatusValidation(Status completion_status, |
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.
above this line you added the ROCKSDB_NAMESPACE:: , please use it here or remove it from the other places.
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 have removed in new code that I have added, however, there are many places in the db_compaction_test.cc that use "ROCKSDB_NAMESPACE::" which I will not touch to avoid unnecessary code changes that are irrelevant to this PR.
@@ -134,32 +386,70 @@ class DBCompactionTestWithParam | |||
bool exclusive_manual_compaction_; | |||
}; | |||
|
|||
class DBCompactionTestWithParamWithMCC |
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.
What is MCC?
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.
Manual Compaction Control
threads_.push_back(std::move(thread)); | ||
} | ||
|
||
void CompactRangeThreadsMngr::CleanupCompletedThreads() { |
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 think joinable() will always return true, because we have never called join().
@@ -622,6 +622,10 @@ Status DBImpl::CloseHelper() { | |||
cfd->UnrefAndTryDelete(); | |||
} | |||
|
|||
// Wait for all non-blocking manual compactions that may still be in progress. | |||
// Do it only after cleaning up all compaction-related activity above. | |||
compact_range_threads_mngr_.Shutdown(); |
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.
great
@@ -2756,6 +2773,8 @@ class DBImpl : public DB { | |||
// The number of LockWAL called without matching UnlockWAL call. | |||
// See also lock_wal_write_token_ | |||
uint32_t lock_wal_count_; | |||
|
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.
maybe add a small comment here about the manual/range compaction thread manager
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 notice
} else { | ||
fprintf(stderr, | ||
"Non-Blocking CompactRange() Didn't Complete Successfuly in " | ||
"Time: %d\n", |
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.
Maybe print the status message?
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.
This is std::future::future_status which is an enum, what status message should I print?
|
||
// An optional completion callback to allow for non-blocking (async) operation | ||
// Default: Empty (Blocking) | ||
std::shared_ptr<CompactRangeCompletedCbIf> async_completion_cb; |
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.
async_completion_cb, maybe use another name, what if we will want to add Async PUT for example?
@@ -36,7 +36,7 @@ class ThreadWithCb { | |||
} | |||
|
|||
ThreadWithCb() {} | |||
bool joinable() { return thread_.joinable(); } | |||
bool joinable() const { return thread_.joinable(); } |
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.
Thank you
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.
Add license here
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 have removed this file
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.
before merge please add comments
|
||
} // namespace | ||
|
||
class DBCompactionTestWithMCC : public DBCompactionTest, |
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 add a note what is MCC.
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.
Done
@@ -2756,6 +2773,8 @@ class DBImpl : public DB { | |||
// The number of LockWAL called without matching UnlockWAL call. | |||
// See also lock_wal_write_token_ | |||
uint32_t lock_wal_count_; | |||
|
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 notice
Add a new option to CompactRangeOptions, a callback object. By defaut, the callback is empty so CompactRange() will be blocking (as it is now). If the callback is set, the callback object's callback method will be called upon completion with the completion status.
129e3d6
to
3cf02ac
Compare
Add a new option to CompactRangeOptions, a callback object. By default, the callback is empty so CompactRange() will be blocking (as it is now). If the callback is set, the callback object's callback method will be called upon completion with the completion status.
Add a new option to CompactRangeOptions, a callback object. By default, the callback is empty so CompactRange() will be blocking (as it is now). If the callback is set, the callback object's callback method will be called upon completion with the completion status.
Add a new option to CompactRangeOptions, a callback object. By defaut, the callback is empty so CompactRange() will be blocking (as it is now). If the callback is set, the callback object's callback method will be called upon completion with the completion status.