0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-29 08:54:02 +01:00

ircd::ctx: Inline cur_slice_cycles().

modules/media/magick: Use this_ctx::cycles_here().

ircd::ctx: Improve prof::cycles API related.
This commit is contained in:
Jason Volk 2019-07-23 16:21:22 -07:00
parent df11d9bec6
commit bde9e16e5c
4 changed files with 14 additions and 15 deletions

View file

@ -92,6 +92,12 @@ struct ircd::ctx::prof::ticker
std::array<uint64_t, num_of<prof::event>()> event {{0}}; std::array<uint64_t, num_of<prof::event>()> event {{0}};
}; };
inline uint64_t
ircd::ctx::prof::cur_slice_cycles()
{
return cycles() - cur_slice_start();
}
extern inline uint64_t extern inline uint64_t
__attribute__((flatten, always_inline, gnu_inline, artificial)) __attribute__((flatten, always_inline, gnu_inline, artificial))
ircd::ctx::prof::cycles() ircd::ctx::prof::cycles()

View file

@ -19,7 +19,7 @@ inline namespace this_ctx
const uint64_t &id(); // Unique ID for cur ctx const uint64_t &id(); // Unique ID for cur ctx
string_view name(); // Optional label for cur ctx string_view name(); // Optional label for cur ctx
ulong cycles_here(); // misc profiling related ulong cycles(); // misc profiling related
bool interruption_requested(); // interruption(cur()) bool interruption_requested(); // interruption(cur())
void interruption_point(); // throws if interruption_requested() void interruption_point(); // throws if interruption_requested()
@ -126,6 +126,12 @@ ircd::ctx::this_ctx::wait(const duration &d)
return duration_cast<duration>(ret); return duration_cast<duration>(ret);
} }
inline ulong
ircd::ctx::this_ctx::cycles()
{
return cycles(cur()) + prof::cur_slice_cycles();
}
/// Reference to the currently running context. Call if you expect to be in a /// Reference to the currently running context. Call if you expect to be in a
/// context. Otherwise use the ctx::current pointer. /// context. Otherwise use the ctx::current pointer.
inline ircd::ctx::ctx & inline ircd::ctx::ctx &

View file

@ -646,13 +646,6 @@ ircd::ctx::this_ctx::yield()
}; };
} }
ulong
ircd::ctx::this_ctx::cycles_here()
{
assert(current);
return cycles(cur()) + prof::cur_slice_cycles();
}
size_t size_t
ircd::ctx::this_ctx::stack_at_here() ircd::ctx::this_ctx::stack_at_here()
{ {
@ -1827,12 +1820,6 @@ ircd::ctx::prof::slice_exceeded_warning(const ulong &cycles)
return threshold > 0 && cycles >= threshold; return threshold > 0 && cycles >= threshold;
} }
ulong
ircd::ctx::prof::cur_slice_cycles()
{
return cycles() - cur_slice_start();
}
const ulong & const ulong &
ircd::ctx::prof::cur_slice_start() ircd::ctx::prof::cur_slice_start()
{ {

View file

@ -546,7 +546,7 @@ noexcept try
// and monotonically increases across jobs as well. // and monotonically increases across jobs as well.
const auto cycles_sample const auto cycles_sample
{ {
cycles(ctx::cur()) + ctx::prof::cur_slice_cycles() ctx::this_ctx::cycles()
}; };
// Detect if this is a new job. Tick is usually zero for a new job, but for // Detect if this is a new job. Tick is usually zero for a new job, but for