mirror of https://github.com/facebook/rocksdb.git
Fix initialization-order-fiasco in write_stall_stats.cc (#11355)
Summary: **Context/Summary:** As title. Pull Request resolved: https://github.com/facebook/rocksdb/pull/11355 Test Plan: - Ran previously failed tests and they succeed - Perf `./db_bench -seed=1679014417652004 -db=/dev/shm/testdb/ -statistics=false -benchmarks="fillseq[-X60]" -key_size=32 -value_size=512 -num=100000 -db_write_buffer_size=655 -target_file_size_base=655 -disable_auto_compactions=false -compression_type=none -bloom_bits=3` Reviewed By: ajkr Differential Revision: D44719333 Pulled By: hx235 fbshipit-source-id: 23d22f314144071d97f7106ff1241c31c0bdf08b
This commit is contained in:
parent
b45738622a
commit
7f5b9f40cb
|
@ -2109,25 +2109,26 @@ TEST_F(DBPropertiesTest, GetMapPropertyBlockCacheEntryStats) {
|
||||||
|
|
||||||
TEST_F(DBPropertiesTest, WriteStallStatsSanityCheck) {
|
TEST_F(DBPropertiesTest, WriteStallStatsSanityCheck) {
|
||||||
for (uint32_t i = 0; i < static_cast<uint32_t>(WriteStallCause::kNone); ++i) {
|
for (uint32_t i = 0; i < static_cast<uint32_t>(WriteStallCause::kNone); ++i) {
|
||||||
std::string str = kWriteStallCauseToHyphenString[i];
|
WriteStallCause cause = static_cast<WriteStallCause>(i);
|
||||||
|
const std::string& str = WriteStallCauseToHyphenString(cause);
|
||||||
ASSERT_TRUE(!str.empty())
|
ASSERT_TRUE(!str.empty())
|
||||||
<< "Please ensure mapping from `WriteStallCause` to "
|
<< "Please ensure mapping from `WriteStallCause` to "
|
||||||
"`kWriteStallCauseToHyphenString` is complete";
|
"`WriteStallCauseToHyphenString` is complete";
|
||||||
WriteStallCause cause = static_cast<WriteStallCause>(i);
|
|
||||||
if (cause == WriteStallCause::kCFScopeWriteStallCauseEnumMax ||
|
if (cause == WriteStallCause::kCFScopeWriteStallCauseEnumMax ||
|
||||||
cause == WriteStallCause::kDBScopeWriteStallCauseEnumMax) {
|
cause == WriteStallCause::kDBScopeWriteStallCauseEnumMax) {
|
||||||
ASSERT_EQ(str, kInvalidWriteStallCauseHyphenString)
|
ASSERT_EQ(str, InvalidWriteStallHyphenString())
|
||||||
<< "Please ensure order in `kWriteStallCauseToHyphenString` is "
|
<< "Please ensure order in `WriteStallCauseToHyphenString` is "
|
||||||
"consistent with `WriteStallCause`";
|
"consistent with `WriteStallCause`";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint32_t i = 0; i < static_cast<uint32_t>(WriteStallCondition::kNormal);
|
for (uint32_t i = 0; i < static_cast<uint32_t>(WriteStallCondition::kNormal);
|
||||||
++i) {
|
++i) {
|
||||||
std::string str = kWriteStallConditionToHyphenString[i];
|
WriteStallCondition condition = static_cast<WriteStallCondition>(i);
|
||||||
|
const std::string& str = WriteStallConditionToHyphenString(condition);
|
||||||
ASSERT_TRUE(!str.empty())
|
ASSERT_TRUE(!str.empty())
|
||||||
<< "Please ensure mapping from `WriteStallCondition` to "
|
<< "Please ensure mapping from `WriteStallCondition` to "
|
||||||
"`kWriteStallConditionToHyphenString` is complete";
|
"`WriteStallConditionToHyphenString` is complete";
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint32_t i = 0; i < static_cast<uint32_t>(WriteStallCause::kNone); ++i) {
|
for (uint32_t i = 0; i < static_cast<uint32_t>(WriteStallCause::kNone); ++i) {
|
||||||
|
|
|
@ -6,26 +6,46 @@
|
||||||
#include "db/write_stall_stats.h"
|
#include "db/write_stall_stats.h"
|
||||||
|
|
||||||
namespace ROCKSDB_NAMESPACE {
|
namespace ROCKSDB_NAMESPACE {
|
||||||
const std::string kInvalidWriteStallCauseHyphenString = "invalid";
|
const std::string& InvalidWriteStallHyphenString() {
|
||||||
|
static const std::string kInvalidWriteStallHyphenString = "invalid";
|
||||||
|
return kInvalidWriteStallHyphenString;
|
||||||
|
}
|
||||||
|
|
||||||
const std::array<std::string, static_cast<uint32_t>(WriteStallCause::kNone)>
|
const std::string& WriteStallCauseToHyphenString(WriteStallCause cause) {
|
||||||
kWriteStallCauseToHyphenString{{
|
static const std::string kMemtableLimit = "memtable-limit";
|
||||||
"memtable-limit",
|
static const std::string kL0FileCountLimit = "l0-file-count-limit";
|
||||||
"l0-file-count-limit",
|
static const std::string kPendingCompactionBytes = "pending-compaction-bytes";
|
||||||
"pending-compaction-bytes",
|
static const std::string kWriteBufferManagerLimit =
|
||||||
// WriteStallCause::kCFScopeWriteStallCauseEnumMax
|
"write-buffer-manager-limit";
|
||||||
kInvalidWriteStallCauseHyphenString,
|
switch (cause) {
|
||||||
"write-buffer-manager-limit",
|
case WriteStallCause::kMemtableLimit:
|
||||||
// WriteStallCause::kDBScopeWriteStallCauseEnumMax
|
return kMemtableLimit;
|
||||||
kInvalidWriteStallCauseHyphenString,
|
case WriteStallCause::kL0FileCountLimit:
|
||||||
}};
|
return kL0FileCountLimit;
|
||||||
|
case WriteStallCause::kPendingCompactionBytes:
|
||||||
|
return kPendingCompactionBytes;
|
||||||
|
case WriteStallCause::kWriteBufferManagerLimit:
|
||||||
|
return kWriteBufferManagerLimit;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return InvalidWriteStallHyphenString();
|
||||||
|
}
|
||||||
|
|
||||||
const std::array<std::string,
|
const std::string& WriteStallConditionToHyphenString(
|
||||||
static_cast<uint32_t>(WriteStallCondition::kNormal)>
|
WriteStallCondition condition) {
|
||||||
kWriteStallConditionToHyphenString{{
|
static const std::string kDelayed = "delays";
|
||||||
"delays",
|
static const std::string kStopped = "stops";
|
||||||
"stops",
|
switch (condition) {
|
||||||
}};
|
case WriteStallCondition::kDelayed:
|
||||||
|
return kDelayed;
|
||||||
|
case WriteStallCondition::kStopped:
|
||||||
|
return kStopped;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return InvalidWriteStallHyphenString();
|
||||||
|
}
|
||||||
|
|
||||||
InternalStats::InternalCFStatsType InternalCFStat(
|
InternalStats::InternalCFStatsType InternalCFStat(
|
||||||
WriteStallCause cause, WriteStallCondition condition) {
|
WriteStallCause cause, WriteStallCondition condition) {
|
||||||
|
@ -139,14 +159,14 @@ std::string WriteStallStatsMapKeys::CauseConditionCount(
|
||||||
|
|
||||||
std::string cause_name;
|
std::string cause_name;
|
||||||
if (isCFScopeWriteStallCause(cause) || isDBScopeWriteStallCause(cause)) {
|
if (isCFScopeWriteStallCause(cause) || isDBScopeWriteStallCause(cause)) {
|
||||||
cause_name = kWriteStallCauseToHyphenString[static_cast<uint32_t>(cause)];
|
cause_name = WriteStallCauseToHyphenString(cause);
|
||||||
} else {
|
} else {
|
||||||
assert(false);
|
assert(false);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& condition_name =
|
const std::string& condition_name =
|
||||||
kWriteStallConditionToHyphenString[static_cast<uint32_t>(condition)];
|
WriteStallConditionToHyphenString(condition);
|
||||||
|
|
||||||
cause_condition_count_name.reserve(cause_name.size() + 1 +
|
cause_condition_count_name.reserve(cause_name.size() + 1 +
|
||||||
condition_name.size());
|
condition_name.size());
|
||||||
|
|
|
@ -11,15 +11,12 @@
|
||||||
#include "rocksdb/types.h"
|
#include "rocksdb/types.h"
|
||||||
|
|
||||||
namespace ROCKSDB_NAMESPACE {
|
namespace ROCKSDB_NAMESPACE {
|
||||||
extern const std::string kInvalidWriteStallCauseHyphenString;
|
extern const std::string& InvalidWriteStallHyphenString();
|
||||||
|
|
||||||
extern const std::array<std::string,
|
extern const std::string& WriteStallCauseToHyphenString(WriteStallCause cause);
|
||||||
static_cast<uint32_t>(WriteStallCause::kNone)>
|
|
||||||
kWriteStallCauseToHyphenString;
|
|
||||||
|
|
||||||
extern const std::array<std::string,
|
extern const std::string& WriteStallConditionToHyphenString(
|
||||||
static_cast<uint32_t>(WriteStallCondition::kNormal)>
|
WriteStallCondition condition);
|
||||||
kWriteStallConditionToHyphenString;
|
|
||||||
|
|
||||||
// REQUIRES:
|
// REQUIRES:
|
||||||
// cause` is CF-scope `WriteStallCause`, see `WriteStallCause` for more
|
// cause` is CF-scope `WriteStallCause`, see `WriteStallCause` for more
|
||||||
|
|
Loading…
Reference in New Issue