mirror of https://github.com/facebook/rocksdb.git
Add `write_memtable_time` to perf level `kEnableWait` (#12394)
Summary: .. so write time can be measured under the new perf level for single-threaded writes. Pull Request resolved: https://github.com/facebook/rocksdb/pull/12394 Test Plan: * add a new UT `PerfContextTest.WriteMemtableTimePerfLevel` Reviewed By: anand1976 Differential Revision: D54326263 Pulled By: cbi42 fbshipit-source-id: d0e334d9581851ba6cf53c776c0bd876365d1e00
This commit is contained in:
parent
13ef21c22e
commit
4aed229fa7
|
@ -325,7 +325,7 @@ Status DBImpl::WriteImpl(const WriteOptions& write_options,
|
|||
|
||||
if (w.ShouldWriteToMemtable()) {
|
||||
PERF_TIMER_STOP(write_pre_and_post_process_time);
|
||||
PERF_TIMER_GUARD(write_memtable_time);
|
||||
PERF_TIMER_FOR_WAIT_GUARD(write_memtable_time);
|
||||
|
||||
ColumnFamilyMemTablesImpl column_family_memtables(
|
||||
versions_->GetColumnFamilySet());
|
||||
|
@ -557,7 +557,7 @@ Status DBImpl::WriteImpl(const WriteOptions& write_options,
|
|||
}
|
||||
|
||||
if (status.ok()) {
|
||||
PERF_TIMER_GUARD(write_memtable_time);
|
||||
PERF_TIMER_FOR_WAIT_GUARD(write_memtable_time);
|
||||
|
||||
if (!parallel) {
|
||||
// w.sequence will be set inside InsertInto
|
||||
|
@ -797,7 +797,7 @@ Status DBImpl::PipelinedWriteImpl(const WriteOptions& write_options,
|
|||
WriteThread::WriteGroup memtable_write_group;
|
||||
|
||||
if (w.state == WriteThread::STATE_MEMTABLE_WRITER_LEADER) {
|
||||
PERF_TIMER_GUARD(write_memtable_time);
|
||||
PERF_TIMER_FOR_WAIT_GUARD(write_memtable_time);
|
||||
assert(w.ShouldWriteToMemtable());
|
||||
write_thread_.EnterAsMemTableWriter(&w, &memtable_write_group);
|
||||
if (memtable_write_group.size > 1 &&
|
||||
|
@ -820,7 +820,7 @@ Status DBImpl::PipelinedWriteImpl(const WriteOptions& write_options,
|
|||
|
||||
if (w.state == WriteThread::STATE_PARALLEL_MEMTABLE_WRITER) {
|
||||
PERF_TIMER_STOP(write_pre_and_post_process_time);
|
||||
PERF_TIMER_GUARD(write_memtable_time);
|
||||
PERF_TIMER_FOR_WAIT_GUARD(write_memtable_time);
|
||||
|
||||
assert(w.ShouldWriteToMemtable());
|
||||
ColumnFamilyMemTablesImpl column_family_memtables(
|
||||
|
@ -868,7 +868,7 @@ Status DBImpl::UnorderedWriteMemtable(const WriteOptions& write_options,
|
|||
RecordTick(stats_, NUMBER_KEYS_WRITTEN, total_count);
|
||||
|
||||
PERF_TIMER_STOP(write_pre_and_post_process_time);
|
||||
PERF_TIMER_GUARD(write_memtable_time);
|
||||
PERF_TIMER_FOR_WAIT_GUARD(write_memtable_time);
|
||||
|
||||
ColumnFamilyMemTablesImpl column_family_memtables(
|
||||
versions_->GetColumnFamilySet());
|
||||
|
|
|
@ -1121,6 +1121,23 @@ TEST_F(PerfContextTest, MergeOperandCount) {
|
|||
verify();
|
||||
}
|
||||
|
||||
TEST_F(PerfContextTest, WriteMemtableTimePerfLevel) {
|
||||
// Write and check time
|
||||
ASSERT_OK(DestroyDB(kDbName, Options()));
|
||||
std::shared_ptr<DB> db = OpenDb();
|
||||
|
||||
SetPerfLevel(PerfLevel::kEnableWait);
|
||||
PerfContext* perf_ctx = get_perf_context();
|
||||
perf_ctx->Reset();
|
||||
ASSERT_OK(db->Put(WriteOptions(), "foo1", "bar"));
|
||||
ASSERT_GT(perf_context.write_memtable_time, 0);
|
||||
|
||||
SetPerfLevel(PerfLevel::kEnableCount);
|
||||
perf_ctx->Reset();
|
||||
ASSERT_OK(db->Put(WriteOptions(), "foo0", "bar"));
|
||||
ASSERT_EQ(perf_context.write_memtable_time, 0);
|
||||
}
|
||||
|
||||
} // namespace ROCKSDB_NAMESPACE
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
* Add `write_memtable_time` to the newly introduced PerfLevel `kEnableWait`.
|
Loading…
Reference in New Issue