diff --git a/include/ircd/db/database/database.h b/include/ircd/db/database/database.h index 4b598b7bf..1ae4358fa 100644 --- a/include/ircd/db/database/database.h +++ b/include/ircd/db/database/database.h @@ -35,18 +35,6 @@ namespace ircd::db const rocksdb::Cache *cache(const database &); rocksdb::Cache *cache(database &); - // Ticker - extern const uint32_t ticker_max; - string_view ticker_id(const uint32_t &id); - uint32_t ticker_id(const string_view &key); - uint64_t ticker(const database &, const uint32_t &id); - uint64_t ticker(const database &, const string_view &key); - - // Histogram - extern const uint32_t histogram_max; - string_view histogram_id(const uint32_t &id); - uint32_t histogram_id(const string_view &key); - // Control panel void setopt(database &, const string_view &key, const string_view &val); void fdeletions(database &, const bool &enable, const bool &force = false); diff --git a/include/ircd/db/db.h b/include/ircd/db/db.h index f9f476b0f..db3495709 100644 --- a/include/ircd/db/db.h +++ b/include/ircd/db/db.h @@ -76,6 +76,7 @@ enum class ircd::db::pos #include "index.h" #include "json.h" #include "txn.h" +#include "stats.h" // // Misc utils @@ -87,14 +88,6 @@ namespace ircd::db std::string path(const std::string &name); std::vector available(); - uint perf_level(); - void perf_level(const uint &); - const rocksdb::PerfContext &perf_current(); - std::string string(const rocksdb::PerfContext &, const bool &all = false); - - const rocksdb::IOStatsContext &iostats_current(); - std::string string(const rocksdb::IOStatsContext &, const bool &all = false); - string_view reflect(const pos &); } diff --git a/include/ircd/db/stats.h b/include/ircd/db/stats.h new file mode 100644 index 000000000..da84b8b58 --- /dev/null +++ b/include/ircd/db/stats.h @@ -0,0 +1,37 @@ +// Matrix Construct +// +// Copyright (C) Matrix Construct Developers, Authors & Contributors +// Copyright (C) 2016-2018 Jason Volk +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice is present in all copies. The +// full license for this software is available in the LICENSE file. + +#pragma once +#define HAVE_IRCD_DB_STATS_H + +namespace ircd::db +{ + // Histogram (per database) + extern const uint32_t histogram_max; + string_view histogram_id(const uint32_t &id); + uint32_t histogram_id(const string_view &key); + + // Ticker (per database) + extern const uint32_t ticker_max; + string_view ticker_id(const uint32_t &id); + uint32_t ticker_id(const string_view &key); + uint64_t ticker(const database &, const uint32_t &id); + uint64_t ticker(const database &, const string_view &key); + + // Perf counts (global) + uint perf_level(); + void perf_level(const uint &); + const rocksdb::PerfContext &perf_current(); + std::string string(const rocksdb::PerfContext &, const bool &all = false); + + // IO counters (global) + const rocksdb::IOStatsContext &iostats_current(); + std::string string(const rocksdb::IOStatsContext &, const bool &all = false); +} diff --git a/ircd/db.cc b/ircd/db.cc index fa9599185..c5d11fa11 100644 --- a/ircd/db.cc +++ b/ircd/db.cc @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -1301,7 +1302,7 @@ catch(const std::exception &e) /////////////////////////////////////////////////////////////////////////////// // -// database::stats +// db/stats.h // std::string @@ -1432,6 +1433,11 @@ ircd::db::histogram_max rocksdb::HISTOGRAM_ENUM_MAX }; +/////////////////////////////////////////////////////////////////////////////// +// +// database::stats (db/database/stats.h) internal +// + uint64_t ircd::db::database::stats::getAndResetTickerCount(const uint32_t type) noexcept