From 74778bd02465639079add39fb9fdb266445be90b Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Wed, 10 Apr 2019 22:52:33 -0700 Subject: [PATCH] ircd::ios: Add a queued handler counter to stats. --- include/ircd/ios.h | 9 ++++++++- ircd/ios.cc | 1 + modules/console.cc | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/ircd/ios.h b/include/ircd/ios.h index 65cbcf0f9..8256cecd0 100644 --- a/include/ircd/ios.h +++ b/include/ircd/ios.h @@ -97,6 +97,7 @@ 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}; @@ -160,7 +161,10 @@ ircd::ios::handle::handle(ios::descriptor &d, function&& f) :handler{&d} ,f{std::forward(f)} -{} +{ + assert(d.stats); + d.stats->queued++; +} template template @@ -168,6 +172,9 @@ void ircd::ios::handle::operator()(args&&... a) const { + assert(descriptor && descriptor->stats); + assert(descriptor->stats->queued > 0); + descriptor->stats->queued--; f(std::forward(a)...); } diff --git a/ircd/ios.cc b/ircd/ios.cc index bdb4c6bda..aae7aaf17 100644 --- a/ircd/ios.cc +++ b/ircd/ios.cc @@ -175,6 +175,7 @@ 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; diff --git a/modules/console.cc b/modules/console.cc index 91e8204c9..d55ccaf29 100644 --- a/modules/console.cc +++ b/modules/console.cc @@ -837,6 +837,7 @@ console_cmd__ios(opt &out, const string_view &line) << " " << std::right << std::setw(10) << "FREES" << " " << std::right << std::setw(26) << "ALLOCATED" << " " << std::right << std::setw(26) << "FREED" + << " " << std::right << std::setw(8) << "QUEUED" << " " << std::right << std::setw(8) << "FAULTS" << std::endl ; @@ -852,6 +853,7 @@ console_cmd__ios(opt &out, const string_view &line) << " " << std::right << std::setw(10) << s.frees << " " << std::right << std::setw(26) << pretty(iec(s.alloc_bytes)) << " " << std::right << std::setw(26) << pretty(iec(s.free_bytes)) + << " " << std::right << std::setw(8) << s.queued << " " << std::right << std::setw(8) << s.faults ; }};