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

ircd::ctx: Measure and report epoch span for slice_usage_warning.

This commit is contained in:
Jason Volk 2020-05-24 16:43:56 -07:00
parent f070e3b706
commit ac42d4df13
2 changed files with 16 additions and 1 deletions

View file

@ -22,6 +22,7 @@ struct ircd::ctx::this_ctx::slice_usage_warning
{ {
string_view fmt; string_view fmt;
va_rtti ap; va_rtti ap;
ulong epoch;
ulong start; ulong start;
template<class... args> template<class... args>

View file

@ -917,6 +917,12 @@ ircd::ctx::this_ctx::slice_usage_warning::slice_usage_warning(const string_view
{ {
std::move(ap) std::move(ap)
} }
,epoch
{
current?
ircd::ctx::epoch(cur()):
ircd::ctx::epoch()
}
,start ,start
{ {
// Set the start value to the total number of cycles accrued by this // Set the start value to the total number of cycles accrued by this
@ -956,6 +962,13 @@ noexcept
if(likely(!prof::slice_exceeded_warning(total))) if(likely(!prof::slice_exceeded_warning(total)))
return; return;
const auto span
{
current?
ircd::ctx::epoch(cur()) - this->epoch:
ircd::ctx::epoch() - this->epoch
};
thread_local char buf[256]; thread_local char buf[256];
const string_view reason{fmt::vsprintf const string_view reason{fmt::vsprintf
{ {
@ -965,12 +978,13 @@ noexcept
const ulong &threshold{prof::settings::slice_warning}; const ulong &threshold{prof::settings::slice_warning};
log::dwarning log::dwarning
{ {
log, "[%s] context id:%lu watchdog :timeslice excessive; lim:%lu this:%lu pct:%.2lf :%s", log, "[%s] context id:%lu watchdog :timeslice excessive; lim:%lu this:%lu pct:%.2lf span:%lu :%s",
current? name(cur()) : ""_sv, current? name(cur()) : ""_sv,
current? id(cur()) : 0, current? id(cur()) : 0,
threshold, threshold,
total, total,
(double(total) / double(threshold)) * 100.0, (double(total) / double(threshold)) * 100.0,
span,
reason reason
}; };
} }