Rename InternalDBStatsType enum names (#5779)

Summary:
When building with clang 9, warning is reported for InternalDBStatsType type names shadowed the one for statistics. Rename them.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/5779

Test Plan: Build with clang 9 and see it passes.

Differential Revision: D17239378

fbshipit-source-id: af28fb42066c738cd1b841f9fe21ab4671dafd18
main
sdong 5 years ago committed by Facebook Github Bot
parent cbfa729d37
commit adbc25a4c8
  1. 45
      db/db_impl/db_impl_write.cc
  2. 19
      db/internal_stats.cc
  3. 40
      db/internal_stats.h

@ -294,18 +294,19 @@ Status DBImpl::WriteImpl(const WriteOptions& write_options,
// We're optimistic, updating the stats before we successfully // We're optimistic, updating the stats before we successfully
// commit. That lets us release our leader status early. // commit. That lets us release our leader status early.
auto stats = default_cf_internal_stats_; auto stats = default_cf_internal_stats_;
stats->AddDBStats(InternalStats::NUMBER_KEYS_WRITTEN, total_count, stats->AddDBStats(InternalStats::kIntStatsNumKeysWritten, total_count,
concurrent_update); concurrent_update);
RecordTick(stats_, NUMBER_KEYS_WRITTEN, total_count); RecordTick(stats_, NUMBER_KEYS_WRITTEN, total_count);
stats->AddDBStats(InternalStats::BYTES_WRITTEN, total_byte_size, stats->AddDBStats(InternalStats::kIntStatsBytesWritten, total_byte_size,
concurrent_update); concurrent_update);
RecordTick(stats_, BYTES_WRITTEN, total_byte_size); RecordTick(stats_, BYTES_WRITTEN, total_byte_size);
stats->AddDBStats(InternalStats::WRITE_DONE_BY_SELF, 1, concurrent_update); stats->AddDBStats(InternalStats::kIntStatsWriteDoneBySelf, 1,
concurrent_update);
RecordTick(stats_, WRITE_DONE_BY_SELF); RecordTick(stats_, WRITE_DONE_BY_SELF);
auto write_done_by_other = write_group.size - 1; auto write_done_by_other = write_group.size - 1;
if (write_done_by_other > 0) { if (write_done_by_other > 0) {
stats->AddDBStats(InternalStats::WRITE_DONE_BY_OTHER, write_done_by_other, stats->AddDBStats(InternalStats::kIntStatsWriteDoneByOther,
concurrent_update); write_done_by_other, concurrent_update);
RecordTick(stats_, WRITE_DONE_BY_OTHER, write_done_by_other); RecordTick(stats_, WRITE_DONE_BY_OTHER, write_done_by_other);
} }
RecordInHistogram(stats_, BYTES_PER_WRITE, total_byte_size); RecordInHistogram(stats_, BYTES_PER_WRITE, total_byte_size);
@ -503,9 +504,9 @@ Status DBImpl::PipelinedWriteImpl(const WriteOptions& write_options,
} }
auto stats = default_cf_internal_stats_; auto stats = default_cf_internal_stats_;
stats->AddDBStats(InternalStats::NUMBER_KEYS_WRITTEN, total_count); stats->AddDBStats(InternalStats::kIntStatsNumKeysWritten, total_count);
RecordTick(stats_, NUMBER_KEYS_WRITTEN, total_count); RecordTick(stats_, NUMBER_KEYS_WRITTEN, total_count);
stats->AddDBStats(InternalStats::BYTES_WRITTEN, total_byte_size); stats->AddDBStats(InternalStats::kIntStatsBytesWritten, total_byte_size);
RecordTick(stats_, BYTES_WRITTEN, total_byte_size); RecordTick(stats_, BYTES_WRITTEN, total_byte_size);
RecordInHistogram(stats_, BYTES_PER_WRITE, total_byte_size); RecordInHistogram(stats_, BYTES_PER_WRITE, total_byte_size);
@ -513,10 +514,10 @@ Status DBImpl::PipelinedWriteImpl(const WriteOptions& write_options,
if (w.status.ok() && !write_options.disableWAL) { if (w.status.ok() && !write_options.disableWAL) {
PERF_TIMER_GUARD(write_wal_time); PERF_TIMER_GUARD(write_wal_time);
stats->AddDBStats(InternalStats::WRITE_DONE_BY_SELF, 1); stats->AddDBStats(InternalStats::kIntStatsWriteDoneBySelf, 1);
RecordTick(stats_, WRITE_DONE_BY_SELF, 1); RecordTick(stats_, WRITE_DONE_BY_SELF, 1);
if (wal_write_group.size > 1) { if (wal_write_group.size > 1) {
stats->AddDBStats(InternalStats::WRITE_DONE_BY_OTHER, stats->AddDBStats(InternalStats::kIntStatsWriteDoneByOther,
wal_write_group.size - 1); wal_write_group.size - 1);
RecordTick(stats_, WRITE_DONE_BY_OTHER, wal_write_group.size - 1); RecordTick(stats_, WRITE_DONE_BY_OTHER, wal_write_group.size - 1);
} }
@ -593,7 +594,7 @@ Status DBImpl::UnorderedWriteMemtable(const WriteOptions& write_options,
w.sequence = seq; w.sequence = seq;
size_t total_count = WriteBatchInternal::Count(my_batch); size_t total_count = WriteBatchInternal::Count(my_batch);
InternalStats* stats = default_cf_internal_stats_; InternalStats* stats = default_cf_internal_stats_;
stats->AddDBStats(InternalStats::NUMBER_KEYS_WRITTEN, total_count); stats->AddDBStats(InternalStats::kIntStatsNumKeysWritten, total_count);
RecordTick(stats_, NUMBER_KEYS_WRITTEN, total_count); RecordTick(stats_, NUMBER_KEYS_WRITTEN, total_count);
ColumnFamilyMemTablesImpl column_family_memtables( ColumnFamilyMemTablesImpl column_family_memtables(
@ -703,15 +704,16 @@ Status DBImpl::WriteImplWALOnly(
// We're optimistic, updating the stats before we successfully // We're optimistic, updating the stats before we successfully
// commit. That lets us release our leader status early. // commit. That lets us release our leader status early.
auto stats = default_cf_internal_stats_; auto stats = default_cf_internal_stats_;
stats->AddDBStats(InternalStats::BYTES_WRITTEN, total_byte_size, stats->AddDBStats(InternalStats::kIntStatsBytesWritten, total_byte_size,
concurrent_update); concurrent_update);
RecordTick(stats_, BYTES_WRITTEN, total_byte_size); RecordTick(stats_, BYTES_WRITTEN, total_byte_size);
stats->AddDBStats(InternalStats::WRITE_DONE_BY_SELF, 1, concurrent_update); stats->AddDBStats(InternalStats::kIntStatsWriteDoneBySelf, 1,
concurrent_update);
RecordTick(stats_, WRITE_DONE_BY_SELF); RecordTick(stats_, WRITE_DONE_BY_SELF);
auto write_done_by_other = write_group.size - 1; auto write_done_by_other = write_group.size - 1;
if (write_done_by_other > 0) { if (write_done_by_other > 0) {
stats->AddDBStats(InternalStats::WRITE_DONE_BY_OTHER, write_done_by_other, stats->AddDBStats(InternalStats::kIntStatsWriteDoneByOther,
concurrent_update); write_done_by_other, concurrent_update);
RecordTick(stats_, WRITE_DONE_BY_OTHER, write_done_by_other); RecordTick(stats_, WRITE_DONE_BY_OTHER, write_done_by_other);
} }
RecordInHistogram(stats_, BYTES_PER_WRITE, total_byte_size); RecordInHistogram(stats_, BYTES_PER_WRITE, total_byte_size);
@ -1043,12 +1045,12 @@ Status DBImpl::WriteToWAL(const WriteThread::WriteGroup& write_group,
if (status.ok()) { if (status.ok()) {
auto stats = default_cf_internal_stats_; auto stats = default_cf_internal_stats_;
if (need_log_sync) { if (need_log_sync) {
stats->AddDBStats(InternalStats::WAL_FILE_SYNCED, 1); stats->AddDBStats(InternalStats::kIntStatsWalFileSynced, 1);
RecordTick(stats_, WAL_FILE_SYNCED); RecordTick(stats_, WAL_FILE_SYNCED);
} }
stats->AddDBStats(InternalStats::WAL_FILE_BYTES, log_size); stats->AddDBStats(InternalStats::kIntStatsWalFileBytes, log_size);
RecordTick(stats_, WAL_FILE_BYTES, log_size); RecordTick(stats_, WAL_FILE_BYTES, log_size);
stats->AddDBStats(InternalStats::WRITE_WITH_WAL, write_with_wal); stats->AddDBStats(InternalStats::kIntStatsWriteWithWal, write_with_wal);
RecordTick(stats_, WRITE_WITH_WAL, write_with_wal); RecordTick(stats_, WRITE_WITH_WAL, write_with_wal);
} }
return status; return status;
@ -1094,9 +1096,10 @@ Status DBImpl::ConcurrentWriteToWAL(const WriteThread::WriteGroup& write_group,
if (status.ok()) { if (status.ok()) {
const bool concurrent = true; const bool concurrent = true;
auto stats = default_cf_internal_stats_; auto stats = default_cf_internal_stats_;
stats->AddDBStats(InternalStats::WAL_FILE_BYTES, log_size, concurrent); stats->AddDBStats(InternalStats::kIntStatsWalFileBytes, log_size,
concurrent);
RecordTick(stats_, WAL_FILE_BYTES, log_size); RecordTick(stats_, WAL_FILE_BYTES, log_size);
stats->AddDBStats(InternalStats::WRITE_WITH_WAL, write_with_wal, stats->AddDBStats(InternalStats::kIntStatsWriteWithWal, write_with_wal,
concurrent); concurrent);
RecordTick(stats_, WRITE_WITH_WAL, write_with_wal); RecordTick(stats_, WRITE_WITH_WAL, write_with_wal);
} }
@ -1398,8 +1401,8 @@ Status DBImpl::DelayWrite(uint64_t num_bytes,
} }
assert(!delayed || !write_options.no_slowdown); assert(!delayed || !write_options.no_slowdown);
if (delayed) { if (delayed) {
default_cf_internal_stats_->AddDBStats(InternalStats::WRITE_STALL_MICROS, default_cf_internal_stats_->AddDBStats(
time_delayed); InternalStats::kIntStatsWriteStallMicros, time_delayed);
RecordTick(stats_, STALL_MICROS, time_delayed); RecordTick(stats_, STALL_MICROS, time_delayed);
} }

@ -954,14 +954,17 @@ void InternalStats::DumpDBStats(std::string* value) {
seconds_up, interval_seconds_up); seconds_up, interval_seconds_up);
value->append(buf); value->append(buf);
// Cumulative // Cumulative
uint64_t user_bytes_written = GetDBStats(InternalStats::BYTES_WRITTEN); uint64_t user_bytes_written =
uint64_t num_keys_written = GetDBStats(InternalStats::NUMBER_KEYS_WRITTEN); GetDBStats(InternalStats::kIntStatsBytesWritten);
uint64_t write_other = GetDBStats(InternalStats::WRITE_DONE_BY_OTHER); uint64_t num_keys_written =
uint64_t write_self = GetDBStats(InternalStats::WRITE_DONE_BY_SELF); GetDBStats(InternalStats::kIntStatsNumKeysWritten);
uint64_t wal_bytes = GetDBStats(InternalStats::WAL_FILE_BYTES); uint64_t write_other = GetDBStats(InternalStats::kIntStatsWriteDoneByOther);
uint64_t wal_synced = GetDBStats(InternalStats::WAL_FILE_SYNCED); uint64_t write_self = GetDBStats(InternalStats::kIntStatsWriteDoneBySelf);
uint64_t write_with_wal = GetDBStats(InternalStats::WRITE_WITH_WAL); uint64_t wal_bytes = GetDBStats(InternalStats::kIntStatsWalFileBytes);
uint64_t write_stall_micros = GetDBStats(InternalStats::WRITE_STALL_MICROS); uint64_t wal_synced = GetDBStats(InternalStats::kIntStatsWalFileSynced);
uint64_t write_with_wal = GetDBStats(InternalStats::kIntStatsWriteWithWal);
uint64_t write_stall_micros =
GetDBStats(InternalStats::kIntStatsWriteStallMicros);
const int kHumanMicrosLen = 32; const int kHumanMicrosLen = 32;
char human_micros[kHumanMicrosLen]; char human_micros[kHumanMicrosLen];

@ -109,15 +109,15 @@ class InternalStats {
}; };
enum InternalDBStatsType { enum InternalDBStatsType {
WAL_FILE_BYTES, kIntStatsWalFileBytes,
WAL_FILE_SYNCED, kIntStatsWalFileSynced,
BYTES_WRITTEN, kIntStatsBytesWritten,
NUMBER_KEYS_WRITTEN, kIntStatsNumKeysWritten,
WRITE_DONE_BY_OTHER, kIntStatsWriteDoneByOther,
WRITE_DONE_BY_SELF, kIntStatsWriteDoneBySelf,
WRITE_WITH_WAL, kIntStatsWriteWithWal,
WRITE_STALL_MICROS, kIntStatsWriteStallMicros,
INTERNAL_DB_STATS_ENUM_MAX, kIntStatsNumMax,
}; };
InternalStats(int num_levels, Env* env, ColumnFamilyData* cfd) InternalStats(int num_levels, Env* env, ColumnFamilyData* cfd)
@ -322,7 +322,7 @@ class InternalStats {
}; };
void Clear() { void Clear() {
for (int i = 0; i < INTERNAL_DB_STATS_ENUM_MAX; i++) { for (int i = 0; i < kIntStatsNumMax; i++) {
db_stats_[i].store(0); db_stats_[i].store(0);
} }
for (int i = 0; i < INTERNAL_CF_STATS_ENUM_MAX; i++) { for (int i = 0; i < INTERNAL_CF_STATS_ENUM_MAX; i++) {
@ -416,7 +416,7 @@ class InternalStats {
bool HandleBlockCacheStat(Cache** block_cache); bool HandleBlockCacheStat(Cache** block_cache);
// Per-DB stats // Per-DB stats
std::atomic<uint64_t> db_stats_[INTERNAL_DB_STATS_ENUM_MAX]; std::atomic<uint64_t> db_stats_[kIntStatsNumMax];
// Per-ColumnFamily stats // Per-ColumnFamily stats
uint64_t cf_stats_value_[INTERNAL_CF_STATS_ENUM_MAX]; uint64_t cf_stats_value_[INTERNAL_CF_STATS_ENUM_MAX];
uint64_t cf_stats_count_[INTERNAL_CF_STATS_ENUM_MAX]; uint64_t cf_stats_count_[INTERNAL_CF_STATS_ENUM_MAX];
@ -615,15 +615,15 @@ class InternalStats {
}; };
enum InternalDBStatsType { enum InternalDBStatsType {
WAL_FILE_BYTES, kIntStatsWalFileBytes,
WAL_FILE_SYNCED, kIntStatsWalFileSynced,
BYTES_WRITTEN, kIntStatsBytesWritten,
NUMBER_KEYS_WRITTEN, kIntStatsNumKeysWritten,
WRITE_DONE_BY_OTHER, kIntStatsWriteDoneByOther,
WRITE_DONE_BY_SELF, kIntStatsWriteDoneBySelf,
WRITE_WITH_WAL, kIntStatsWriteWithWal,
WRITE_STALL_MICROS, kIntStatsWriteStallMicros,
INTERNAL_DB_STATS_ENUM_MAX, kIntStatsNumMax,
}; };
InternalStats(int /*num_levels*/, Env* /*env*/, ColumnFamilyData* /*cfd*/) {} InternalStats(int /*num_levels*/, Env* /*env*/, ColumnFamilyData* /*cfd*/) {}

Loading…
Cancel
Save