From 63c850b123469e815d963a9f69ca4efa551e3c9f Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Tue, 2 Apr 2019 11:09:37 -0700 Subject: [PATCH] ircd: Rename perf:: to prof::. --- include/ircd/ctx/prof.h | 8 ++++++++ include/ircd/ircd.h | 2 +- include/ircd/{perf.h => prof.h} | 24 ++++++++++++------------ ircd/Makefile.am | 2 +- ircd/ctx.cc | 10 +++++----- ircd/ios.cc | 6 +++--- ircd/ircd.cc | 2 +- ircd/{perf.cc => prof.cc} | 8 ++++---- 8 files changed, 35 insertions(+), 27 deletions(-) rename include/ircd/{perf.h => prof.h} (85%) rename ircd/{perf.cc => prof.cc} (86%) diff --git a/include/ircd/ctx/prof.h b/include/ircd/ctx/prof.h index ceccfd3a8..c7f0d5ae2 100644 --- a/include/ircd/ctx/prof.h +++ b/include/ircd/ctx/prof.h @@ -32,6 +32,7 @@ namespace ircd::ctx::prof enum class event :uint8_t; struct ticker; + uint64_t cycles(); string_view reflect(const event &); // totals @@ -95,3 +96,10 @@ struct ircd::ctx::prof::ticker // monotonic counters for events std::array()> event {{0}}; }; + +inline uint64_t +__attribute__((flatten, always_inline, gnu_inline, artificial)) +ircd::ctx::prof::cycles() +{ + return ircd::prof::cycles(); +} diff --git a/include/ircd/ircd.h b/include/ircd/ircd.h index 728d793f8..333661c03 100644 --- a/include/ircd/ircd.h +++ b/include/ircd/ircd.h @@ -47,7 +47,7 @@ #include "magics.h" #include "conf.h" #include "stats.h" -#include "perf.h" +#include "prof.h" #include "fs/fs.h" #include "ios.h" #include "ctx/ctx.h" diff --git a/include/ircd/perf.h b/include/ircd/prof.h similarity index 85% rename from include/ircd/perf.h rename to include/ircd/prof.h index a8727a46e..8d511f7fb 100644 --- a/include/ircd/perf.h +++ b/include/ircd/prof.h @@ -9,9 +9,9 @@ // full license for this software is available in the LICENSE file. #pragma once -#define HAVE_IRCD_PERF_H +#define HAVE_IRCD_PROF_H -namespace ircd::perf +namespace ircd::prof { struct init; @@ -26,10 +26,10 @@ namespace ircd::perf namespace ircd { - using perf::cycles; + using prof::cycles; } -struct ircd::perf::init +struct ircd::prof::init { init(); ~init() noexcept; @@ -37,21 +37,21 @@ struct ircd::perf::init inline uint64_t __attribute__((flatten, always_inline, gnu_inline, artificial)) -ircd::perf::cycles() +ircd::prof::cycles() { - return perf::rdtsc(); + return prof::rdtsc(); } #if defined(__x86_64__) || defined(__i386__) inline unsigned long long __attribute__((always_inline, gnu_inline, artificial)) -ircd::perf::rdtsc() +ircd::prof::rdtsc() { return __builtin_ia32_rdtsc(); } #else inline unsigned long long -ircd::perf::rdtsc() +ircd::prof::rdtsc() { static_assert(false, "TODO: Implement fallback here"); return 0; @@ -61,14 +61,14 @@ ircd::perf::rdtsc() #if defined(__x86_64__) || defined(__i386__) inline unsigned long long __attribute__((always_inline, gnu_inline, artificial)) -ircd::perf::rdtscp() +ircd::prof::rdtscp() { uint32_t ia32_tsc_aux; return __builtin_ia32_rdtscp(&ia32_tsc_aux); } #else inline unsigned long long -ircd::perf::rdtscp() +ircd::prof::rdtscp() { static_assert(false, "TODO: Implement fallback here"); return 0; @@ -78,13 +78,13 @@ ircd::perf::rdtscp() #if defined(__x86_64__) || defined(__i386__) inline unsigned long long __attribute__((always_inline, gnu_inline, artificial)) -ircd::perf::rdpmc(const uint &c) +ircd::prof::rdpmc(const uint &c) { return __builtin_ia32_rdpmc(c); } #else inline unsigned long long -ircd::perf::rdpmc(const uint &c) +ircd::prof::rdpmc(const uint &c) { static_assert(false, "TODO: Implement fallback here"); return 0; diff --git a/ircd/Makefile.am b/ircd/Makefile.am index 67ee411e1..bc765a138 100644 --- a/ircd/Makefile.am +++ b/ircd/Makefile.am @@ -116,7 +116,7 @@ libircd_la_SOURCES = \ logger.cc \ magic.cc \ stats.cc \ - perf.cc \ + prof.cc \ fs.cc \ sodium.cc \ openssl.cc \ diff --git a/ircd/ctx.cc b/ircd/ctx.cc index dea162c6b..dd3e1899e 100644 --- a/ircd/ctx.cc +++ b/ircd/ctx.cc @@ -872,7 +872,7 @@ ircd::ctx::this_ctx::slice_usage_warning::slice_usage_warning(const string_view // Set the start value to the total number of cycles accrued by this // context including the current time slice. !current? - perf::cycles(): + prof::cycles(): ~cur().flags & context::SLICE_EXEMPT? cur().profile.cycles + prof::cur_slice_cycles(): 0 @@ -898,7 +898,7 @@ noexcept { current? cur().profile.cycles + prof::cur_slice_cycles(): - perf::cycles() + prof::cycles() }; assert(stop >= start); @@ -1663,13 +1663,13 @@ ircd::ctx::prof::handle_cur_continue() void ircd::ctx::prof::slice_enter() { - _slice_start = perf::cycles(); + _slice_start = cycles(); } void ircd::ctx::prof::slice_leave() { - _slice_stop = perf::cycles(); + _slice_stop = cycles(); auto &c(cur()); assert(_slice_stop >= _slice_start); @@ -1811,7 +1811,7 @@ ircd::ctx::prof::slice_exceeded_warning(const ulong &cycles) ulong ircd::ctx::prof::cur_slice_cycles() { - return perf::cycles() - cur_slice_start(); + return cycles() - cur_slice_start(); } const ulong & diff --git a/ircd/ios.cc b/ircd/ios.cc index 1ed5721f2..bdb4c6bda 100644 --- a/ircd/ios.cc +++ b/ircd/ios.cc @@ -208,7 +208,7 @@ ircd::ios::handler::fault(handler *const &handler) // needs to be tied off here instead. if(!ret) { - stats.slice_last = perf::cycles() - handler->slice_start; + stats.slice_last = cycles() - handler->slice_start; stats.slice_total += stats.slice_last; assert(handler::current == handler); @@ -226,7 +226,7 @@ ircd::ios::handler::leave(handler *const &handler) assert(descriptor.stats); auto &stats(*descriptor.stats); - stats.slice_last = perf::cycles() - handler->slice_start; + stats.slice_last = cycles() - handler->slice_start; stats.slice_total += stats.slice_last; assert(handler::current == handler); @@ -245,7 +245,7 @@ ircd::ios::handler::enter(handler *const &handler) assert(!handler::current); handler::current = handler; - handler->slice_start = perf::cycles(); + handler->slice_start = cycles(); } bool diff --git a/ircd/ircd.cc b/ircd/ircd.cc index 056c8cf04..3beb14cc8 100644 --- a/ircd/ircd.cc +++ b/ircd/ircd.cc @@ -202,7 +202,7 @@ noexcept try // more appropriate. fs::init _fs_; // Local filesystem - perf::init _perf_; // Profiling related + prof::init _prof_; // Profiling related magic::init _magic_; // libmagic ctx::ole::init _ole_; // Thread OffLoad Engine nacl::init _nacl_; // nacl crypto diff --git a/ircd/perf.cc b/ircd/prof.cc similarity index 86% rename from ircd/perf.cc rename to ircd/prof.cc index 0c17c76df..e82518b0b 100644 --- a/ircd/perf.cc +++ b/ircd/prof.cc @@ -17,24 +17,24 @@ // #ifdef HAVE_LINUX_PERF_EVENT_H -ircd::perf::init::init() +ircd::prof::init::init() { } #else -ircd::perf::init::init() +ircd::prof::init::init() { } #endif #ifdef HAVE_LINUX_PERF_EVENT_H -ircd::perf::init::~init() +ircd::prof::init::~init() noexcept { } #else -ircd::perf::init::~init() +ircd::prof::init::~init() noexcept { }