mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 18:22:50 +01:00
ircd::ctx::prof: Add cycle counter to ticker array.
This commit is contained in:
parent
0ce0fe3890
commit
8c68a24e1f
3 changed files with 18 additions and 14 deletions
|
@ -83,6 +83,7 @@ enum class ircd::ctx::prof::event
|
|||
CONTINUE, // Current context continuing
|
||||
INTERRUPT, // Current context detects interruption
|
||||
TERMINATE, // Current context detects termination
|
||||
CYCLES, // monotonic counter (rdtsc)
|
||||
|
||||
_NUM_
|
||||
};
|
||||
|
@ -90,9 +91,6 @@ enum class ircd::ctx::prof::event
|
|||
/// structure aggregating any profiling related state for a ctx
|
||||
struct ircd::ctx::prof::ticker
|
||||
{
|
||||
// monotonic counter (rdtsc)
|
||||
ulong cycles {0};
|
||||
|
||||
// monotonic counters for events
|
||||
std::array<uint64_t, num_of<prof::event>()> event {{0}};
|
||||
};
|
||||
|
|
22
ircd/ctx.cc
22
ircd/ctx.cc
|
@ -509,7 +509,7 @@ noexcept
|
|||
const ulong &
|
||||
ircd::ctx::cycles(const ctx &ctx)
|
||||
{
|
||||
return ctx.profile.cycles;
|
||||
return prof::get(ctx, prof::event::CYCLES);
|
||||
}
|
||||
|
||||
/// Returns the yield count for `ctx`
|
||||
|
@ -918,7 +918,7 @@ ircd::ctx::this_ctx::slice_usage_warning::slice_usage_warning(const string_view
|
|||
!current?
|
||||
prof::cycles():
|
||||
~cur().flags & context::SLICE_EXEMPT?
|
||||
cur().profile.cycles + prof::cur_slice_cycles():
|
||||
prof::get(cur(), prof::event::CYCLES) + prof::cur_slice_cycles():
|
||||
0
|
||||
}
|
||||
{
|
||||
|
@ -941,7 +941,7 @@ noexcept
|
|||
const auto stop
|
||||
{
|
||||
current?
|
||||
cur().profile.cycles + prof::cur_slice_cycles():
|
||||
prof::get(cur(), prof::event::CYCLES) + prof::cur_slice_cycles():
|
||||
prof::cycles()
|
||||
};
|
||||
|
||||
|
@ -1717,10 +1717,19 @@ ircd::ctx::prof::slice_leave()
|
|||
|
||||
auto &c(cur());
|
||||
assert(_slice_stop >= _slice_start);
|
||||
const auto last_slice(_slice_stop - _slice_start);
|
||||
const auto last_slice
|
||||
{
|
||||
_slice_stop - _slice_start
|
||||
};
|
||||
|
||||
static constexpr auto pos
|
||||
{
|
||||
size_t(prof::event::CYCLES)
|
||||
};
|
||||
|
||||
c.profile.event.at(pos) += last_slice;
|
||||
_total.event.at(pos) += last_slice;
|
||||
c.stack.at = stack_at_here();
|
||||
c.profile.cycles += last_slice;
|
||||
_total.cycles += last_slice;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
@ -1903,6 +1912,7 @@ ircd::ctx::prof::reflect(const event &e)
|
|||
case event::CONTINUE: return "CONTINUE";
|
||||
case event::INTERRUPT: return "INTERRUPT";
|
||||
case event::TERMINATE: return "TERMINATE";
|
||||
case event::CYCLES: return "CYCLES";
|
||||
case event::_NUM_: break;
|
||||
}
|
||||
|
||||
|
|
|
@ -1486,10 +1486,6 @@ console_cmd__ctx__prof(opt &out, const string_view &line)
|
|||
<< " " << t.event.at(uint8_t(event))
|
||||
<< std::endl;
|
||||
});
|
||||
|
||||
out << std::left << std::setw(15) << std::setfill('_') << "cycles"
|
||||
<< " " << t.cycles
|
||||
<< std::endl;
|
||||
}};
|
||||
|
||||
if(!param["id"])
|
||||
|
@ -1592,7 +1588,7 @@ console_cmd__ctx__list(opt &out, const string_view &line)
|
|||
out << " "
|
||||
<< std::setw(15) << std::right << cycles(ctx);
|
||||
|
||||
const long double total_cyc(ctx::prof::get().cycles);
|
||||
const long double total_cyc(ctx::prof::get(ctx, ctx::prof::event::CYCLES));
|
||||
const auto tsc_pct
|
||||
{
|
||||
total_cyc > 0.0? (cycles(ctx) / total_cyc) : 0.0L
|
||||
|
|
Loading…
Reference in a new issue