0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-29 20:28:52 +02:00

ircd::db: Additional custom stats tickers for PinnableSlice copy and referencing.

This commit is contained in:
Jason Volk 2020-06-17 18:51:35 -07:00
parent c0990e0c0b
commit 54996d2f29
2 changed files with 61 additions and 7 deletions

View file

@ -2626,6 +2626,26 @@ namespace ircd::db
ircd::db::database::stats::stats(database *const &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());
for(size_t i(0); i < item.size(); ++i)
@ -8049,8 +8069,14 @@ ircd::db::_read(column &column,
if(likely(closure))
closure(value);
// triggered when the result was not zero-copy
assert(!opts.fill_cache || buf.empty());
// Update stats about whether the pinnable slices we obtained have internal
// copies or referencing the cache copy.
{
database &d(column);
d.stats->get_copied += !buf.empty();
d.stats->get_referenced += buf.empty();
}
return ret;
}
@ -8147,11 +8173,33 @@ ircd::db::_read(const vector_view<_read_op> &op,
return false;
}
//#ifdef IRCD_DB_HAS_MULTIGET_DIRECT
// triggered when the result was not zero-copy
static const auto not_empty{[](auto &&s) { return !s.empty(); }};
assert(!ropts.fill_cache || !std::count_if(buf, buf + num, not_empty));
//#endif
// Update stats about whether the pinnable slices we obtained have internal
// copies or referencing the cache copy.
{
database &d(std::get<column>(op[0]));
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;
}

View file

@ -323,6 +323,12 @@ struct ircd::db::database::stats final
std::array<ircd::stats::item<uint64_t *>, NUM_TICKER> item;
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
uint64_t getTickerCount(const uint32_t tickerType) const noexcept override;