mirror of
https://github.com/matrix-construct/construct
synced 2024-12-02 03:32:52 +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
|
CONTINUE, // Current context continuing
|
||||||
INTERRUPT, // Current context detects interruption
|
INTERRUPT, // Current context detects interruption
|
||||||
TERMINATE, // Current context detects termination
|
TERMINATE, // Current context detects termination
|
||||||
|
CYCLES, // monotonic counter (rdtsc)
|
||||||
|
|
||||||
_NUM_
|
_NUM_
|
||||||
};
|
};
|
||||||
|
@ -90,9 +91,6 @@ enum class ircd::ctx::prof::event
|
||||||
/// structure aggregating any profiling related state for a ctx
|
/// structure aggregating any profiling related state for a ctx
|
||||||
struct ircd::ctx::prof::ticker
|
struct ircd::ctx::prof::ticker
|
||||||
{
|
{
|
||||||
// monotonic counter (rdtsc)
|
|
||||||
ulong cycles {0};
|
|
||||||
|
|
||||||
// monotonic counters for events
|
// monotonic counters for events
|
||||||
std::array<uint64_t, num_of<prof::event>()> event {{0}};
|
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 &
|
const ulong &
|
||||||
ircd::ctx::cycles(const ctx &ctx)
|
ircd::ctx::cycles(const ctx &ctx)
|
||||||
{
|
{
|
||||||
return ctx.profile.cycles;
|
return prof::get(ctx, prof::event::CYCLES);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the yield count for `ctx`
|
/// Returns the yield count for `ctx`
|
||||||
|
@ -918,7 +918,7 @@ ircd::ctx::this_ctx::slice_usage_warning::slice_usage_warning(const string_view
|
||||||
!current?
|
!current?
|
||||||
prof::cycles():
|
prof::cycles():
|
||||||
~cur().flags & context::SLICE_EXEMPT?
|
~cur().flags & context::SLICE_EXEMPT?
|
||||||
cur().profile.cycles + prof::cur_slice_cycles():
|
prof::get(cur(), prof::event::CYCLES) + prof::cur_slice_cycles():
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -941,7 +941,7 @@ noexcept
|
||||||
const auto stop
|
const auto stop
|
||||||
{
|
{
|
||||||
current?
|
current?
|
||||||
cur().profile.cycles + prof::cur_slice_cycles():
|
prof::get(cur(), prof::event::CYCLES) + prof::cur_slice_cycles():
|
||||||
prof::cycles()
|
prof::cycles()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1717,10 +1717,19 @@ ircd::ctx::prof::slice_leave()
|
||||||
|
|
||||||
auto &c(cur());
|
auto &c(cur());
|
||||||
assert(_slice_stop >= _slice_start);
|
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.stack.at = stack_at_here();
|
||||||
c.profile.cycles += last_slice;
|
|
||||||
_total.cycles += last_slice;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
@ -1903,6 +1912,7 @@ ircd::ctx::prof::reflect(const event &e)
|
||||||
case event::CONTINUE: return "CONTINUE";
|
case event::CONTINUE: return "CONTINUE";
|
||||||
case event::INTERRUPT: return "INTERRUPT";
|
case event::INTERRUPT: return "INTERRUPT";
|
||||||
case event::TERMINATE: return "TERMINATE";
|
case event::TERMINATE: return "TERMINATE";
|
||||||
|
case event::CYCLES: return "CYCLES";
|
||||||
case event::_NUM_: break;
|
case event::_NUM_: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1486,10 +1486,6 @@ console_cmd__ctx__prof(opt &out, const string_view &line)
|
||||||
<< " " << t.event.at(uint8_t(event))
|
<< " " << t.event.at(uint8_t(event))
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
});
|
});
|
||||||
|
|
||||||
out << std::left << std::setw(15) << std::setfill('_') << "cycles"
|
|
||||||
<< " " << t.cycles
|
|
||||||
<< std::endl;
|
|
||||||
}};
|
}};
|
||||||
|
|
||||||
if(!param["id"])
|
if(!param["id"])
|
||||||
|
@ -1592,7 +1588,7 @@ console_cmd__ctx__list(opt &out, const string_view &line)
|
||||||
out << " "
|
out << " "
|
||||||
<< std::setw(15) << std::right << cycles(ctx);
|
<< 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
|
const auto tsc_pct
|
||||||
{
|
{
|
||||||
total_cyc > 0.0? (cycles(ctx) / total_cyc) : 0.0L
|
total_cyc > 0.0? (cycles(ctx) / total_cyc) : 0.0L
|
||||||
|
|
Loading…
Reference in a new issue