mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 02:02:38 +01:00
ircd::prof: Move ctx::syscall_usage_warning into prof.
This commit is contained in:
parent
726422f576
commit
6679b66806
7 changed files with 61 additions and 56 deletions
|
@ -83,7 +83,6 @@ namespace ircd::ctx
|
|||
#include "sleep.h"
|
||||
#include "stack_usage_assertion.h"
|
||||
#include "slice_usage_warning.h"
|
||||
#include "syscall_usage_warning.h"
|
||||
#include "critical_assertion.h"
|
||||
#include "critical_indicator.h"
|
||||
#include "exception_handler.h"
|
||||
|
|
|
@ -39,6 +39,7 @@ namespace ircd::prof
|
|||
#include "cycles.h"
|
||||
#include "scope_cycles.h"
|
||||
#include "syscall_timer.h"
|
||||
#include "syscall_usage_warning.h"
|
||||
#include "instructions.h"
|
||||
#include "resource.h"
|
||||
#include "times.h"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Matrix Construct
|
||||
// The Construct
|
||||
//
|
||||
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
||||
// Copyright (C) 2016-2019 Jason Volk <jason@zemos.net>
|
||||
// Copyright (C) The Construct Developers, Authors & Contributors
|
||||
// Copyright (C) 2016-2020 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
|
||||
|
@ -9,16 +9,15 @@
|
|||
// full license for this software is available in the LICENSE file.
|
||||
|
||||
#pragma once
|
||||
#define HAVE_IRCD_CTX_SYSCALL_USAGE_WARNING_H
|
||||
#define HAVE_IRCD_PROF_SYSCALL_USAGE_WARNING_H
|
||||
|
||||
namespace ircd::ctx {
|
||||
inline namespace this_ctx
|
||||
namespace ircd::prof
|
||||
{
|
||||
struct syscall_usage_warning;
|
||||
}}
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
struct ircd::ctx::this_ctx::syscall_usage_warning
|
||||
#ifdef RB_DEBUG
|
||||
struct ircd::prof::syscall_usage_warning
|
||||
{
|
||||
const string_view fmt;
|
||||
const va_rtti ap;
|
||||
|
@ -37,7 +36,7 @@ struct ircd::ctx::this_ctx::syscall_usage_warning
|
|||
~syscall_usage_warning() noexcept;
|
||||
};
|
||||
#else
|
||||
struct ircd::ctx::this_ctx::syscall_usage_warning
|
||||
struct ircd::prof::syscall_usage_warning
|
||||
{
|
||||
syscall_usage_warning(const string_view &fmt, ...)
|
||||
{
|
41
ircd/ctx.cc
41
ircd/ctx.cc
|
@ -924,47 +924,6 @@ noexcept
|
|||
}
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// ctx/syscall_usage_warning.h
|
||||
//
|
||||
|
||||
#ifndef NDEBUG
|
||||
ircd::ctx::this_ctx::syscall_usage_warning::~syscall_usage_warning()
|
||||
noexcept
|
||||
{
|
||||
const uint64_t total
|
||||
{
|
||||
timer.stopped?
|
||||
timer.at():
|
||||
timer.sample()
|
||||
};
|
||||
|
||||
if(likely(!total))
|
||||
return;
|
||||
|
||||
thread_local char buf[512];
|
||||
const string_view reason
|
||||
{
|
||||
fmt::vsprintf{buf, fmt, ap}
|
||||
};
|
||||
|
||||
thread_local char tmbuf[64];
|
||||
log::dwarning
|
||||
{
|
||||
log, "[%s] context id:%lu watchdog :system call took %s :%s",
|
||||
current?
|
||||
name(cur()):
|
||||
ios::handler::current?
|
||||
name(*ios::handler::current):
|
||||
"*"_sv,
|
||||
current? id(cur()) : 0,
|
||||
pretty_nanoseconds(tmbuf, total, true),
|
||||
reason
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// ctx/slice_usage_warning.h
|
||||
|
|
|
@ -461,7 +461,7 @@ ircd::fs::sync(const fd &fd,
|
|||
const sync_opts &opts)
|
||||
{
|
||||
assert(opts.op == op::SYNC);
|
||||
const ctx::syscall_usage_warning message
|
||||
const prof::syscall_usage_warning message
|
||||
{
|
||||
"fs::sync(fd:%d)", int(fd)
|
||||
};
|
||||
|
@ -504,7 +504,7 @@ ircd::fs::flush(const fd &fd,
|
|||
}
|
||||
#endif
|
||||
|
||||
const ctx::syscall_usage_warning message
|
||||
const prof::syscall_usage_warning message
|
||||
{
|
||||
"fs::flush(fd:%d, {metadata:%b aio:%b:%b})",
|
||||
int(fd),
|
||||
|
@ -1705,7 +1705,7 @@ ircd::fs::fd::fd(const string_view &path,
|
|||
:fdno{[&path, &opts]
|
||||
() -> int
|
||||
{
|
||||
const ctx::syscall_usage_warning message
|
||||
const prof::syscall_usage_warning message
|
||||
{
|
||||
"fs::fs::fd(): open(2): %s", path
|
||||
};
|
||||
|
|
|
@ -932,7 +932,7 @@ try
|
|||
count_queued(op::SYNC),
|
||||
};
|
||||
|
||||
ctx::syscall_usage_warning warning
|
||||
prof::syscall_usage_warning warning
|
||||
{
|
||||
"fs::aio::system::submit(in_flight:%zu qcount:%zu r:%zu w:%zu s:%zu)",
|
||||
in_flight,
|
||||
|
|
47
ircd/prof.cc
47
ircd/prof.cc
|
@ -95,6 +95,53 @@ noexcept
|
|||
start();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// prof/syscall_usage_warning.h
|
||||
//
|
||||
|
||||
#ifdef RB_DEBUG
|
||||
ircd::prof::syscall_usage_warning::~syscall_usage_warning()
|
||||
noexcept
|
||||
{
|
||||
const uint64_t total
|
||||
{
|
||||
timer.stopped?
|
||||
timer.at():
|
||||
timer.sample()
|
||||
};
|
||||
|
||||
if(likely(!total))
|
||||
return;
|
||||
|
||||
thread_local char buf[512];
|
||||
const string_view reason
|
||||
{
|
||||
fmt::vsprintf
|
||||
{
|
||||
buf, fmt, ap
|
||||
}
|
||||
};
|
||||
|
||||
thread_local char tmbuf[64];
|
||||
log::dwarning
|
||||
{
|
||||
log, "[%s] context id:%lu watchdog :system call took %s :%s",
|
||||
ctx::current?
|
||||
name(ctx::cur()):
|
||||
ios::handler::current?
|
||||
name(*ios::handler::current):
|
||||
"*"_sv,
|
||||
ctx::current?
|
||||
id(ctx::cur()):
|
||||
0,
|
||||
pretty_nanoseconds(tmbuf, total, true),
|
||||
reason
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// prof/syscall_timer.h
|
||||
|
|
Loading…
Reference in a new issue