From bde9e16e5c4060cde1bee7e423a113bbb8dbcfe7 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Tue, 23 Jul 2019 16:21:22 -0700 Subject: [PATCH] ircd::ctx: Inline cur_slice_cycles(). modules/media/magick: Use this_ctx::cycles_here(). ircd::ctx: Improve prof::cycles API related. --- include/ircd/ctx/prof.h | 6 ++++++ include/ircd/ctx/this_ctx.h | 8 +++++++- ircd/ctx.cc | 13 ------------- modules/media/magick.cc | 2 +- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/include/ircd/ctx/prof.h b/include/ircd/ctx/prof.h index 3d254b866..8160644e7 100644 --- a/include/ircd/ctx/prof.h +++ b/include/ircd/ctx/prof.h @@ -92,6 +92,12 @@ struct ircd::ctx::prof::ticker std::array()> event {{0}}; }; +inline uint64_t +ircd::ctx::prof::cur_slice_cycles() +{ + return cycles() - cur_slice_start(); +} + extern inline uint64_t __attribute__((flatten, always_inline, gnu_inline, artificial)) ircd::ctx::prof::cycles() diff --git a/include/ircd/ctx/this_ctx.h b/include/ircd/ctx/this_ctx.h index d22a500c9..edb1357ae 100644 --- a/include/ircd/ctx/this_ctx.h +++ b/include/ircd/ctx/this_ctx.h @@ -19,7 +19,7 @@ inline namespace this_ctx const uint64_t &id(); // Unique ID 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()) void interruption_point(); // throws if interruption_requested() @@ -126,6 +126,12 @@ ircd::ctx::this_ctx::wait(const duration &d) return duration_cast(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 /// context. Otherwise use the ctx::current pointer. inline ircd::ctx::ctx & diff --git a/ircd/ctx.cc b/ircd/ctx.cc index 68b5013d8..6886b8a1f 100644 --- a/ircd/ctx.cc +++ b/ircd/ctx.cc @@ -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 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; } -ulong -ircd::ctx::prof::cur_slice_cycles() -{ - return cycles() - cur_slice_start(); -} - const ulong & ircd::ctx::prof::cur_slice_start() { diff --git a/modules/media/magick.cc b/modules/media/magick.cc index 901353e53..cf7ab451c 100644 --- a/modules/media/magick.cc +++ b/modules/media/magick.cc @@ -546,7 +546,7 @@ noexcept try // and monotonically increases across jobs as well. 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