diff --git a/include/ircd/ios/descriptor.h b/include/ircd/ios/descriptor.h index 009224985..4e9f26631 100644 --- a/include/ircd/ios/descriptor.h +++ b/include/ircd/ios/descriptor.h @@ -50,21 +50,29 @@ struct ircd::ios::descriptor struct ircd::ios::descriptor::stats { - uint64_t queued {0}; - uint64_t calls {0}; - uint64_t faults {0}; - uint64_t allocs {0}; - uint64_t alloc_bytes{0}; - uint64_t frees {0}; - uint64_t free_bytes{0}; - uint64_t slice_total {0}; - uint64_t slice_last {0}; - uint64_t latency_total {0}; - uint64_t latency_last {0}; + using value_type = uint64_t; + using item = ircd::stats::item; - stats &operator+=(const stats &) &; + value_type value[11]; + size_t items; - stats(); + public: + item queued; + item calls; + item faults; + item allocs; + item alloc_bytes; + item frees; + item free_bytes; + item slice_total; + item slice_last; + item latency_total; + item latency_last; + + stats(descriptor &); + stats() = delete; + stats(const stats &) = delete; + stats &operator=(const stats &) = delete; ~stats() noexcept; }; diff --git a/include/ircd/ios/handler.h b/include/ircd/ios/handler.h index fc0e2f386..1316919e0 100644 --- a/include/ircd/ios/handler.h +++ b/include/ircd/ios/handler.h @@ -136,9 +136,9 @@ noexcept "QUEUE %5u %-30s [%11lu] ------[%9lu] q:%-4lu", descriptor.id, trunc(descriptor.name, 30), - stats.calls, + uint64_t(stats.calls), 0UL, - stats.queued, + uint64_t(stats.queued), }; } diff --git a/ircd/ctx.cc b/ircd/ctx.cc index 608d1b4e7..2d22b7e4b 100644 --- a/ircd/ctx.cc +++ b/ircd/ctx.cc @@ -347,9 +347,9 @@ noexcept try "QUEUE %5u %-30s [%11lu] ------[%9lu] q:%-4lu id:%-5u %-30s", ios_desc.id, trunc(ios_desc.name, 30), - ios_desc.stats->calls, + uint64_t(ios_desc.stats->calls), notes, - ios_desc.stats->queued, + uint64_t(ios_desc.stats->queued), id, name, }; @@ -1745,7 +1745,7 @@ noexcept }; assert(ctx::ios_desc.stats); - const auto &last_slice + const uint64_t &last_slice { ctx::ios_desc.stats->slice_last }; @@ -1769,7 +1769,7 @@ ircd::ctx::prof::check_slice() }; assert(ctx::ios_desc.stats); - const auto &last_slice + const uint64_t &last_slice { ctx::ios_desc.stats->slice_last }; diff --git a/ircd/ios.cc b/ircd/ios.cc index 8b6f74e87..bec3b0dba 100644 --- a/ircd/ios.cc +++ b/ircd/ios.cc @@ -268,7 +268,7 @@ noexcept } ,stats { - std::make_unique() + std::make_unique(*this) } ,allocator { @@ -305,8 +305,106 @@ noexcept // descriptor::stats // -ircd::ios::descriptor::stats::stats() +namespace ircd::ios { + static thread_local char stats_name_buf[128]; + static string_view stats_name(const descriptor &d, const string_view &key); +} + +ircd::string_view +ircd::ios::stats_name(const descriptor &d, + const string_view &key) +{ + return fmt::sprintf + { + stats_name_buf, "ircd.ios.%s.%s", + d.name, + key, + }; +} + +ircd::ios::descriptor::stats::stats(descriptor &d) +:value{0} +,items{0} +,queued +{ + value + items++, + { + { "name", stats_name(d, "queued") }, + }, +} +,calls +{ + value + items++, + { + { "name", stats_name(d, "calls") }, + }, +} +,faults +{ + value + items++, + { + { "name", stats_name(d, "faults") }, + }, +} +,allocs +{ + value + items++, + { + { "name", stats_name(d, "allocs") }, + }, +} +,alloc_bytes +{ + value + items++, + { + { "name", stats_name(d, "alloc_bytes") }, + }, +} +,frees +{ + value + items++, + { + { "name", stats_name(d, "frees") }, + }, +} +,free_bytes +{ + value + items++, + { + { "name", stats_name(d, "free_bytes") }, + }, +} +,slice_total +{ + value + items++, + { + { "name", stats_name(d, "slice_total") }, + }, +} +,slice_last +{ + value + items++, + { + { "name", stats_name(d, "slice_last") }, + }, +} +,latency_total +{ + value + items++, + { + { "name", stats_name(d, "latency_total") }, + }, +} +,latency_last +{ + value + items++, + { + { "name", stats_name(d, "latency_last") }, + }, +} +{ + assert(items <= (sizeof(value) / sizeof(value[0]))); } ircd::ios::descriptor::stats::~stats() @@ -314,24 +412,6 @@ noexcept { } -struct ircd::ios::descriptor::stats & -ircd::ios::descriptor::stats::operator+=(const stats &o) -& -{ - queued += o.queued; - calls += o.calls; - faults += o.faults; - allocs += o.allocs; - alloc_bytes += o.alloc_bytes; - frees += o.frees; - free_bytes += o.free_bytes; - slice_total += o.slice_total; - slice_last += o.slice_last; - latency_total += o.latency_total; - latency_last += o.latency_last; - return *this; -} - // // handler // @@ -368,9 +448,9 @@ noexcept "FAULT %5u %-30s [%11lu] faults[%9lu] q:%-4lu", descriptor.id, trunc(descriptor.name, 30), - stats.calls, - stats.faults, - stats.queued, + uint64_t(stats.calls), + uint64_t(stats.faults), + uint64_t(stats.queued), }; // Our API sez if this function returns true, caller is responsible for @@ -418,9 +498,9 @@ noexcept "LEAVE %5u %-30s [%11lu] cycles[%9lu] q:%-4lu", descriptor.id, trunc(descriptor.name, 30), - stats.calls, - stats.slice_last, - stats.queued, + uint64_t(stats.calls), + uint64_t(stats.slice_last), + uint64_t(stats.queued), }; assert(handler::current == handler); @@ -458,9 +538,9 @@ noexcept "ENTER %5u %-30s [%11lu] latent[%9lu] q:%-4lu", descriptor.id, trunc(descriptor.name, 30), - stats.calls, - stats.latency_last, - stats.queued, + uint64_t(stats.calls), + uint64_t(stats.latency_last), + uint64_t(stats.queued), }; } diff --git a/modules/console.cc b/modules/console.cc index 1ae3e2e39..f140c3305 100644 --- a/modules/console.cc +++ b/modules/console.cc @@ -1683,7 +1683,6 @@ console_cmd__ios(opt &out, const string_view &line) ; }}; - struct ios::descriptor::stats total; for(const auto *const &descriptor : ios::descriptor::list) { assert(descriptor); @@ -1691,19 +1690,15 @@ console_cmd__ios(opt &out, const string_view &line) assert(d.stats); const auto &s(*d.stats); - total += s; - out << std::left << std::setw(3) << d.id - << " " << std::left << std::setw(48) << d.name; + out + << std::left << std::setw(3) << d.id + << " " << std::left << std::setw(48) << d.name; + stats_output(s); out << std::endl; } - out << std::endl; - out << std::left << std::setw(3) << '-' - << " " << std::left << std::setw(48) << "TOTAL"; - stats_output(total); - out << std::endl; return true; }