diff --git a/CMakeLists.txt b/CMakeLists.txt index fbdffb97a..c250ca9ec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -421,6 +421,7 @@ set(TESTS util/options_test.cc util/rate_limiter_test.cc util/slice_transform_test.cc + util/statistics_test.cc util/thread_list_test.cc util/thread_local_test.cc utilities/backupable/backupable_db_test.cc diff --git a/Makefile b/Makefile index 653fc5ab0..d05580cf6 100644 --- a/Makefile +++ b/Makefile @@ -378,6 +378,7 @@ TESTS = \ ldb_cmd_test \ iostats_context_test \ persistent_cache_test \ + statistics_test \ PARALLEL_TEST = \ backupable_db_test \ @@ -1220,6 +1221,9 @@ iostats_context_test: util/iostats_context_test.o $(LIBOBJECTS) $(TESTHARNESS) persistent_cache_test: utilities/persistent_cache/persistent_cache_test.o db/db_test_util.o $(LIBOBJECTS) $(TESTHARNESS) $(AM_LINK) +statistics_test: util/statistics_test.o $(LIBOBJECTS) $(TESTHARNESS) + $(AM_LINK) + #------------------------------------------------- # make install related stuff INSTALL_PATH ?= /usr/local diff --git a/include/rocksdb/statistics.h b/include/rocksdb/statistics.h index 97ba54bf0..16fba0906 100644 --- a/include/rocksdb/statistics.h +++ b/include/rocksdb/statistics.h @@ -216,6 +216,8 @@ const std::vector> TickersNameMap = { {BLOCK_CACHE_BYTES_READ, "rocksdb.block.cache.bytes.read"}, {BLOCK_CACHE_BYTES_WRITE, "rocksdb.block.cache.bytes.write"}, {BLOOM_FILTER_USEFUL, "rocksdb.bloom.filter.useful"}, + {PERSISTENT_CACHE_HIT, "rocksdb.persistent.cache.hit"}, + {PERSISTENT_CACHE_MISS, "rocksdb.persistent.cache.miss"}, {MEMTABLE_HIT, "rocksdb.memtable.hit"}, {MEMTABLE_MISS, "rocksdb.memtable.miss"}, {GET_HIT_L0, "rocksdb.l0.hit"}, @@ -265,10 +267,11 @@ const std::vector> TickersNameMap = { {WAL_FILE_BYTES, "rocksdb.wal.bytes"}, {WRITE_DONE_BY_SELF, "rocksdb.write.self"}, {WRITE_DONE_BY_OTHER, "rocksdb.write.other"}, + {WRITE_TIMEDOUT, "rocksdb.write.timeout"}, {WRITE_WITH_WAL, "rocksdb.write.wal"}, - {FLUSH_WRITE_BYTES, "rocksdb.flush.write.bytes"}, {COMPACT_READ_BYTES, "rocksdb.compact.read.bytes"}, {COMPACT_WRITE_BYTES, "rocksdb.compact.write.bytes"}, + {FLUSH_WRITE_BYTES, "rocksdb.flush.write.bytes"}, {NUMBER_DIRECT_LOAD_TABLE_PROPERTIES, "rocksdb.number.direct.load.table.properties"}, {NUMBER_SUPERVERSION_ACQUIRES, "rocksdb.number.superversion_acquires"}, diff --git a/src.mk b/src.mk index d5761c41f..3b2cbf71a 100644 --- a/src.mk +++ b/src.mk @@ -277,6 +277,7 @@ MAIN_SOURCES = \ util/env_test.cc \ util/filelock_test.cc \ util/histogram_test.cc \ + util/statistics_test.cc \ utilities/backupable/backupable_db_test.cc \ utilities/checkpoint/checkpoint_test.cc \ utilities/document/document_db_test.cc \ diff --git a/util/statistics_test.cc b/util/statistics_test.cc new file mode 100644 index 000000000..ee894a54e --- /dev/null +++ b/util/statistics_test.cc @@ -0,0 +1,35 @@ +// Copyright (c) 2011-present, Facebook, Inc. All rights reserved. +// This source code is licensed under the BSD-style license found in the +// LICENSE file in the root directory of this source tree. An additional grant +// of patent rights can be found in the PATENTS file in the same directory. +// + +#include "port/stack_trace.h" +#include "util/testharness.h" +#include "util/testutil.h" + +#include "rocksdb/statistics.h" + +namespace rocksdb { + +class StatisticsTest : public testing::Test {}; + +// Sanity check to make sure that contents and order of TickersNameMap +// match Tickers enum +TEST_F(StatisticsTest, Sanity) { + EXPECT_EQ(static_cast(Tickers::TICKER_ENUM_MAX), + TickersNameMap.size()); + + for (uint32_t t = 0; t < Tickers::TICKER_ENUM_MAX; t++) { + auto pair = TickersNameMap[static_cast(t)]; + ASSERT_EQ(pair.first, t) << "Miss match at " << pair.second; + } +} + +} // namespace rocksdb + +int main(int argc, char** argv) { + rocksdb::port::InstallStackTraceHandler(); + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +}