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

ircd::prof: Add callgrind hypercall suite.

This commit is contained in:
Jason Volk 2019-04-19 05:47:30 -07:00
parent def7ee2753
commit 55fc2c6f76
3 changed files with 73 additions and 0 deletions

View file

@ -783,6 +783,7 @@ dnl instrumentation
RB_CHK_SYSHEADER(malloc.h, [MALLOC_H]) RB_CHK_SYSHEADER(malloc.h, [MALLOC_H])
RB_CHK_SYSHEADER(valgrind/valgrind.h, [VALGRIND_VALGRIND_H]) RB_CHK_SYSHEADER(valgrind/valgrind.h, [VALGRIND_VALGRIND_H])
RB_CHK_SYSHEADER(valgrind/memcheck.h, [VALGRIND_MEMCHECK_H]) RB_CHK_SYSHEADER(valgrind/memcheck.h, [VALGRIND_MEMCHECK_H])
RB_CHK_SYSHEADER(valgrind/callgrind.h, [VALGRIND_CALLGRIND_H])
dnl experimental dnl experimental
RB_CHK_SYSHEADER(experimental/string_view, [EXPERIMENTAL_STRING_VIEW]) RB_CHK_SYSHEADER(experimental/string_view, [EXPERIMENTAL_STRING_VIEW])

View file

@ -60,11 +60,36 @@ namespace ircd::prof::x86
unsigned long long rdtsc(); unsigned long long rdtsc();
} }
/// Callgrind hypercall suite
namespace ircd::prof::vg
{
struct enable;
struct disable;
void dump(const char *const reason = nullptr);
void toggle();
void reset();
void start() noexcept;
void stop() noexcept;
}
namespace ircd namespace ircd
{ {
using prof::cycles; using prof::cycles;
} }
struct ircd::prof::vg::enable
{
enable() noexcept { start(); }
~enable() noexcept { stop(); }
};
struct ircd::prof::vg::disable
{
disable() noexcept { stop(); }
~disable() noexcept { start(); }
};
struct ircd::prof::times struct ircd::prof::times
{ {
uint64_t real {0}; uint64_t real {0};

View file

@ -13,6 +13,7 @@
#include <RB_INC_SYS_MMAN_H #include <RB_INC_SYS_MMAN_H
#include <RB_INC_SYS_RESOURCE_H #include <RB_INC_SYS_RESOURCE_H
#include <linux/perf_event.h> #include <linux/perf_event.h>
#include <RB_INC_VALGRIND_CALLGRIND_H
#include <boost/chrono/chrono.hpp> #include <boost/chrono/chrono.hpp>
#include <boost/chrono/process_cpu_clocks.hpp> #include <boost/chrono/process_cpu_clocks.hpp>
@ -772,6 +773,52 @@ ircd::prof::time_user()
return boost::chrono::process_user_cpu_clock::now().time_since_epoch().count(); return boost::chrono::process_user_cpu_clock::now().time_since_epoch().count();
} }
//
// prof::vg
//
void
ircd::prof::vg::stop()
noexcept
{
#ifdef HAVE_VALGRIND_CALLGRIND_H
CALLGRIND_STOP_INSTRUMENTATION;
#endif
}
void
ircd::prof::vg::start()
noexcept
{
#ifdef HAVE_VALGRIND_CALLGRIND_H
CALLGRIND_START_INSTRUMENTATION;
#endif
}
void
ircd::prof::vg::reset()
{
#ifdef HAVE_VALGRIND_CALLGRIND_H
CALLGRIND_ZERO_STATS;
#endif
}
void
ircd::prof::vg::toggle()
{
#ifdef HAVE_VALGRIND_CALLGRIND_H
CALLGRIND_TOGGLE_COLLECT;
#endif
}
void
ircd::prof::vg::dump(const char *const reason)
{
#ifdef HAVE_VALGRIND_CALLGRIND_H
CALLGRIND_DUMP_STATS_AT(reason);
#endif
}
// //
// times // times
// //