0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-16 15:00:51 +01:00

ircd::db::database::cache: Add constant conditional verbose debug log msgs.

This commit is contained in:
Jason Volk 2022-06-15 19:10:13 -07:00
parent 6fd08ba0a3
commit 445fe80d75
2 changed files with 42 additions and 5 deletions

View file

@ -24,6 +24,8 @@
#define RB_DEBUG_DB_SEEK 0 #define RB_DEBUG_DB_SEEK 0
#define RB_DEBUG_DB_SEEK_ROW 0 #define RB_DEBUG_DB_SEEK_ROW 0
#define RB_DEBUG_DB_PREFETCH 0 #define RB_DEBUG_DB_PREFETCH 0
#define RB_DEBUG_DB_CACHE 0
#define RB_DEBUG_DB_CACHE_HIT 0
/// Set this #define to 1 or 2 to enable extensive log messages for the /// Set this #define to 1 or 2 to enable extensive log messages for the
/// experimental db environment-port implementation. This is only useful /// experimental db environment-port implementation. This is only useful

View file

@ -3056,6 +3056,8 @@ ircd::db::database::cache::Insert(const Slice &key,
Priority priority) Priority priority)
noexcept noexcept
{ {
using rocksdb::Tickers;
assert(bool(c)); assert(bool(c));
assert(bool(stats)); assert(bool(stats));
@ -3064,9 +3066,25 @@ noexcept
c->Insert(key, value, charge, del, handle, priority) c->Insert(key, value, charge, del, handle, priority)
}; };
stats->recordTick(rocksdb::Tickers::BLOCK_CACHE_ADD, ret.ok()); stats->recordTick(Tickers::BLOCK_CACHE_ADD, ret.ok());
stats->recordTick(rocksdb::Tickers::BLOCK_CACHE_ADD_FAILURES, !ret.ok()); stats->recordTick(Tickers::BLOCK_CACHE_ADD_FAILURES, !ret.ok());
stats->recordTick(rocksdb::Tickers::BLOCK_CACHE_DATA_BYTES_INSERT, ret.ok()? charge : 0UL); stats->recordTick(Tickers::BLOCK_CACHE_DATA_BYTES_INSERT, ret.ok()? charge : 0UL);
char pbuf[48];
if constexpr(RB_DEBUG_DB_CACHE)
log::debug
{
log, "[%s]'%s' CACHED %-3s +%zu:%zu %s :%s%s",
db::name(*d),
this->name,
ret.ok()? "OK"s: ret.ToString(),
stats->getTickerCount(Tickers::BLOCK_CACHE_ADD),
stats->getTickerCount(Tickers::BLOCK_CACHE_ADD_FAILURES),
pretty(pbuf, si(stats->getTickerCount(Tickers::BLOCK_CACHE_DATA_BYTES_INSERT))),
trunc(slice(key), 16),
size(slice(key)) > 16? "..."_sv: string_view{},
};
return ret; return ret;
} }
@ -3075,6 +3093,8 @@ ircd::db::database::cache::Lookup(const Slice &key,
Statistics *const statistics) Statistics *const statistics)
noexcept noexcept
{ {
using rocksdb::Tickers;
assert(bool(c)); assert(bool(c));
assert(bool(this->stats)); assert(bool(this->stats));
@ -3099,8 +3119,23 @@ noexcept
// passing it to Lookup() does nothing internally. We have to do this // passing it to Lookup() does nothing internally. We have to do this
// here ourselves :/ // here ourselves :/
this->stats->recordTick(rocksdb::Tickers::BLOCK_CACHE_HIT, bool(ret)); this->stats->recordTick(Tickers::BLOCK_CACHE_HIT, bool(ret));
this->stats->recordTick(rocksdb::Tickers::BLOCK_CACHE_MISS, !bool(ret)); this->stats->recordTick(Tickers::BLOCK_CACHE_MISS, !bool(ret));
if constexpr(RB_DEBUG_DB_CACHE)
if(likely(RB_DEBUG_DB_CACHE_HIT || !ret))
log::debug
{
log, "[%s]'%s' CACHE %-4s +%zu:%zu :%s%s",
db::name(*d),
this->name,
ret? "HIT": "MISS",
stats->getTickerCount(Tickers::BLOCK_CACHE_HIT),
stats->getTickerCount(Tickers::BLOCK_CACHE_MISS),
trunc(slice(key), 16),
size(slice(key)) > 16? "..."_sv: string_view{},
};
return ret; return ret;
} }