2019-10-09 02:01:48 +02:00
|
|
|
// Matrix Construct
|
|
|
|
//
|
|
|
|
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
|
|
|
// Copyright (C) 2016-2019 Jason Volk <jason@zemos.net>
|
|
|
|
//
|
|
|
|
// Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
|
|
// copyright notice and this permission notice is present in all copies. The
|
|
|
|
// full license for this software is available in the LICENSE file.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#define HAVE_IRCD_PROF_PSI_H
|
|
|
|
|
|
|
|
namespace ircd::prof::psi
|
|
|
|
{
|
|
|
|
struct file;
|
|
|
|
struct metric;
|
2020-05-09 05:06:13 +02:00
|
|
|
struct trigger;
|
2019-10-09 02:01:48 +02:00
|
|
|
|
2020-05-09 02:58:49 +02:00
|
|
|
// Read and update the referenced extern.
|
2019-10-09 02:01:48 +02:00
|
|
|
bool refresh(file &) noexcept;
|
|
|
|
|
2020-05-09 02:58:49 +02:00
|
|
|
// Yield ircd::ctx until event; returns unrefreshed
|
2020-05-09 05:06:13 +02:00
|
|
|
file &wait(const vector_view<const trigger> & = {});
|
2020-05-09 02:58:49 +02:00
|
|
|
|
2019-10-09 02:01:48 +02:00
|
|
|
extern const bool supported;
|
2020-05-09 05:06:13 +02:00
|
|
|
extern const string_view path[3];
|
2019-10-09 02:01:48 +02:00
|
|
|
extern file cpu, mem, io;
|
|
|
|
}
|
|
|
|
|
2020-05-09 05:06:13 +02:00
|
|
|
struct ircd::prof::psi::trigger
|
|
|
|
{
|
|
|
|
const psi::file &file;
|
|
|
|
string_view string;
|
|
|
|
};
|
|
|
|
|
2019-10-09 02:01:48 +02:00
|
|
|
struct ircd::prof::psi::metric
|
|
|
|
{
|
|
|
|
struct avg
|
|
|
|
{
|
|
|
|
seconds window;
|
|
|
|
float pct;
|
|
|
|
};
|
|
|
|
|
2020-05-10 00:52:30 +02:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
microseconds total; // stall value direct from system
|
|
|
|
microseconds relative; // value since last sample only
|
|
|
|
microseconds window; // duration since last sample
|
|
|
|
float pct; // % of stall time since last sample
|
|
|
|
}
|
|
|
|
stall;
|
2019-10-09 02:01:48 +02:00
|
|
|
std::array<struct avg, 3> avg;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ircd::prof::psi::file
|
|
|
|
{
|
|
|
|
string_view name;
|
|
|
|
system_point sampled;
|
|
|
|
metric some, full;
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifndef __linux__
|
|
|
|
inline bool
|
|
|
|
ircd::prof::psi::refresh(metric &)
|
|
|
|
noexcept
|
|
|
|
{
|
|
|
|
return false; // unsupported platform
|
|
|
|
}
|
|
|
|
#endif
|