mirror of
https://github.com/matrix-construct/construct
synced 2024-11-17 23:40:57 +01:00
ircd::db: Additional custom stats tickers for PinnableSlice copy and referencing.
This commit is contained in:
parent
c0990e0c0b
commit
54996d2f29
2 changed files with 61 additions and 7 deletions
62
ircd/db.cc
62
ircd/db.cc
|
@ -2626,6 +2626,26 @@ namespace ircd::db
|
||||||
|
|
||||||
ircd::db::database::stats::stats(database *const &d)
|
ircd::db::database::stats::stats(database *const &d)
|
||||||
:d{d}
|
:d{d}
|
||||||
|
,get_copied
|
||||||
|
{
|
||||||
|
{ "name", make_name("get.copied") },
|
||||||
|
{ "desc", "Number of DB::Get() results violating zero-copy." },
|
||||||
|
}
|
||||||
|
,get_referenced
|
||||||
|
{
|
||||||
|
{ "name", make_name("get.referenced") },
|
||||||
|
{ "desc", "Number of DB::Get() results adhering to zero-copy." },
|
||||||
|
}
|
||||||
|
,multiget_copied
|
||||||
|
{
|
||||||
|
{ "name", make_name("multiget.copied") },
|
||||||
|
{ "desc", "Number of DB::MultiGet() results violating zero-copy." },
|
||||||
|
}
|
||||||
|
,multiget_referenced
|
||||||
|
{
|
||||||
|
{ "name", make_name("multiget.referenced") },
|
||||||
|
{ "desc", "Number of DB::MultiGet() results adhering to zero-copy." },
|
||||||
|
}
|
||||||
{
|
{
|
||||||
assert(item.size() == ticker.size());
|
assert(item.size() == ticker.size());
|
||||||
for(size_t i(0); i < item.size(); ++i)
|
for(size_t i(0); i < item.size(); ++i)
|
||||||
|
@ -8049,8 +8069,14 @@ ircd::db::_read(column &column,
|
||||||
if(likely(closure))
|
if(likely(closure))
|
||||||
closure(value);
|
closure(value);
|
||||||
|
|
||||||
// triggered when the result was not zero-copy
|
// Update stats about whether the pinnable slices we obtained have internal
|
||||||
assert(!opts.fill_cache || buf.empty());
|
// copies or referencing the cache copy.
|
||||||
|
{
|
||||||
|
database &d(column);
|
||||||
|
d.stats->get_copied += !buf.empty();
|
||||||
|
d.stats->get_referenced += buf.empty();
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8147,11 +8173,33 @@ ircd::db::_read(const vector_view<_read_op> &op,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//#ifdef IRCD_DB_HAS_MULTIGET_DIRECT
|
// Update stats about whether the pinnable slices we obtained have internal
|
||||||
// triggered when the result was not zero-copy
|
// copies or referencing the cache copy.
|
||||||
static const auto not_empty{[](auto &&s) { return !s.empty(); }};
|
{
|
||||||
assert(!ropts.fill_cache || !std::count_if(buf, buf + num, not_empty));
|
database &d(std::get<column>(op[0]));
|
||||||
//#endif
|
const auto copy_count
|
||||||
|
{
|
||||||
|
std::count_if(buf, buf + num, [](auto&& s) { return !s.empty(); })
|
||||||
|
};
|
||||||
|
|
||||||
|
auto &referenced
|
||||||
|
{
|
||||||
|
parallelize?
|
||||||
|
d.stats->multiget_referenced:
|
||||||
|
d.stats->get_referenced
|
||||||
|
};
|
||||||
|
|
||||||
|
auto &copied
|
||||||
|
{
|
||||||
|
parallelize?
|
||||||
|
d.stats->multiget_copied:
|
||||||
|
d.stats->get_copied
|
||||||
|
};
|
||||||
|
|
||||||
|
assert(num >= size_t(copy_count));
|
||||||
|
referenced += (num - copy_count);
|
||||||
|
copied += copy_count;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -323,6 +323,12 @@ struct ircd::db::database::stats final
|
||||||
std::array<ircd::stats::item<uint64_t *>, NUM_TICKER> item;
|
std::array<ircd::stats::item<uint64_t *>, NUM_TICKER> item;
|
||||||
std::array<struct db::histogram, NUM_HISTOGRAM> histogram;
|
std::array<struct db::histogram, NUM_HISTOGRAM> histogram;
|
||||||
|
|
||||||
|
// Additional custom stats
|
||||||
|
ircd::stats::item<uint64_t> get_copied;
|
||||||
|
ircd::stats::item<uint64_t> get_referenced;
|
||||||
|
ircd::stats::item<uint64_t> multiget_copied;
|
||||||
|
ircd::stats::item<uint64_t> multiget_referenced;
|
||||||
|
|
||||||
string_view make_name(const string_view &ticker_name) const; // tls buffer
|
string_view make_name(const string_view &ticker_name) const; // tls buffer
|
||||||
|
|
||||||
uint64_t getTickerCount(const uint32_t tickerType) const noexcept override;
|
uint64_t getTickerCount(const uint32_t tickerType) const noexcept override;
|
||||||
|
|
Loading…
Reference in a new issue