57 explicit Backtrace(
size_t skip = 0,
size_t maxDepth = 128);
88 void printPartial(
size_t start, ssize_t
end = -1,
int color = -1)
const;
89 void print(
int color = -1)
const;
90 void printDelta(
Backtrace const& other,
int color = -1)
const;
105 template <
bool Enable = Config::EnablePerfEvent>
156 if(vasprintf(&
str, fmt, args) == -1)
167 if(vasprintf(&
str, fmt, args) == -1)
199 # pragma GCC diagnostic push
200 # pragma GCC diagnostic ignored "-Wunused-parameter"
237 va_list args) noexcept
253 # pragma GCC diagnostic pop
269 # if __cplusplus >= 201103L
271 template <
typename... Args>
292 # define zth_perf_event(...) zth::perf_event(__VA_ARGS__)
295 inline void perf_event(PerfEvent<>
const& event) noexcept
317 # define zth_perf_event(...) zth::perf_event(PerfEvent<>(__VA_ARGS__))
375 template <
typename T =
float>
430 type dt_s = (
type)(now - m_current).s();
467 return dt_s / (
rc() + dt_s);
490 template <
typename T =
float,
size_t Bins = 2,
typename Count = u
int_fast32_t>
504 static_assert(std::numeric_limits<decltype(m_current)>::max() >= Bins,
"");
510 for(; m_binStart + m_window < now && b < Bins; b++) {
512 m_current = (m_current + 1U) % Bins;
513 m_bins[m_current] = 0;
514 m_binStart += m_window;
532 type w = (
type)(now - m_binStart).s() / m_window_s;
542 type first_bin = ((
type)1 - w) * (
type)m_bins[(m_current + 1U) % Bins];
544 type last_bin = (
type)m_bins[m_current];
547 type sum = first_bin + last_bin;
548 for(decltype(m_current + 0) i = 2; i < Bins; i++)
549 sum += (
type)m_bins[(m_current + i) % Bins];
552 return sum * ((
type)1 / (
type)(Bins - 1)) / m_window_s;
617 #define zth_perf_mark(marker) zth_perf_mark_("" marker)
bool truncated() const noexcept
vector_type< void * >::type bt_type
Fiber * fiber() const noexcept
Timestamp const & t0() const noexcept
Timestamp const & t1() const noexcept
uint64_t fiberId() const noexcept
bt_type const & bt() const noexcept
Measure the rate of some event in Hz.
void operator()(Timestamp const &now=Timestamp::now()) noexcept
void event(Timestamp const &now=Timestamp::now()) noexcept
type rate(Timestamp const &now=Timestamp::now()) const noexcept
EventRate(type window=1) noexcept
Measure the load of some activity.
void setRc(type rc) noexcept
type idle(type load, type dt_s) const noexcept
type active(type load, type dt_s) const noexcept
type load(Timestamp const &now) const noexcept
void idle(type dt_s) noexcept
void stop(Timestamp const &now=Timestamp::now()) noexcept
void start(Timestamp const &now=Timestamp::now()) noexcept
type load() const noexcept
void active(type dt_s) noexcept
type alpha(type dt_s) const noexcept
bool isActive() const noexcept
Convenient wrapper around struct timespec that contains a time interval.
Convenient wrapper around struct timespec that contains an absolute timestamp.
void zth_perf_log(char const *fmt,...)
Put a formatted log string into the perf output.
void zth_perf_logv(char const *fmt, va_list args)
Put a formatted log string into the perf output.
#define zth_config(name)
Checks if the given zth::Config field is enabled.
@ end
End-of-guard-list marker.
void perf_mark(char const *marker)
Put a string marker into the perf output.
void perf_log(char const *fmt,...)
Put a formatted log string into the perf output.
#define zth_perf_event(...)
Construct a zth::PerfEvent with provided parameters, and forward it to the perf buffer for later proc...
void perf_logv(char const *fmt, va_list args)
Put a formatted log string into the perf output.
#define ZTH_CLASS_NEW_DELETE(T)
Define new/delete operators for a class, which are allocator-aware.
#define ZTH_TLS_DECLARE(type, var)
__thread perf_eventBuffer_type * perf_eventBuffer
vector_type< PerfEvent<> >::type perf_eventBuffer_type
void perf_flushEventBuffer() noexcept
void perf_event(Args &&... args) noexcept
UniqueID< Fiber > const & currentFiberID() noexcept
string format(char const *fmt,...)
Format like sprintf(), but save the result in an zth::string.
void perf_syscall(char const *syscall, Timestamp const &t=Timestamp())
Put a syscall into the perf output.
void zth_perf_mark_(char const *marker)
static bool const EnablePerfEvent
Enable (but not necessarily record) perf.
static size_t const PerfEventBufferSize
Buffer size for perf events.
static size_t const PerfEventBufferThresholdToTriggerVCDWrite
Threshold when to force writing out VCD buffer.
constexpr PerfEvent(UniqueID< Fiber > const &fiber, string const &str, Timestamp const &t=Timestamp()) noexcept
constexpr PerfEvent() noexcept
constexpr PerfEvent(UniqueID< Fiber > const &fiber, char const *marker, Timestamp const &t=Timestamp()) noexcept
constexpr PerfEvent(UniqueID< Fiber > const &fiber) noexcept
void release() const noexcept
constexpr PerfEvent(UniqueID< Fiber > const &fiber, int state, Timestamp const &t=Timestamp()) noexcept
An event to be processed by perf_event().
constexpr PerfEvent() noexcept
PerfEvent(UniqueID< Fiber > const &fiber, char const *marker, Timestamp const &t=Timestamp::now()) noexcept
PerfEvent(UniqueID< Fiber > const &fiber)
PerfEvent(UniqueID< Fiber > const &fiber, string const &str, Timestamp const &t=Timestamp::now())
PerfEvent(UniqueID< Fiber > const &fiber, int state, Timestamp const &t=Timestamp::now()) noexcept
std::vector type using Config::Allocator::type.
#define zth_assert(expr)
assert(), but better integrated in Zth.
#define unlikely(expr)
Marks the given expression to likely be evaluated to true.