ircd: Toward improving cold/unlikely section population.

This commit is contained in:
Jason Volk 2022-05-26 12:00:07 -07:00
parent f5d3da8d3f
commit 04558290c0
26 changed files with 47 additions and 20 deletions

View File

@ -30,7 +30,7 @@ struct name \
:parent \
{ \
template<class... args> \
[[gnu::noinline]] \
[[gnu::noinline, gnu::cold]] \
name(const string_view &fmt, args&&... ap) noexcept \
:parent{generate_skip} \
{ \
@ -39,7 +39,7 @@ struct name \
} \
\
template<class... args> \
[[gnu::noinline]] \
[[gnu::noinline, gnu::cold]] \
name(const string_view &fmt = " ") noexcept \
:parent{generate_skip} \
{ \

View File

@ -15,6 +15,7 @@
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunreachable-code"
#endif __clang__
[[gnu::cold]]
void
__assert_fail(const char *__assertion,
const char *__file,
@ -70,6 +71,7 @@ __assert_fail(const char *__assertion,
#endif __clang__
#endif
[[gnu::cold]]
void
ircd::print_assertion(const char *const __assertion,
const char *const __file,

View File

@ -253,6 +253,7 @@ ircd::cl::init::init()
log_dev_info();
}
[[gnu::cold]]
ircd::cl::init::~init()
noexcept
{

View File

@ -127,6 +127,7 @@ ircd::client::init::init()
spawn();
}
[[gnu::cold]]
ircd::client::init::~init()
noexcept
{

View File

@ -884,6 +884,7 @@ noexcept
#endif
#ifndef NDEBUG
[[gnu::cold]]
void
ircd::ctx::assert_critical()
{

View File

@ -40,6 +40,7 @@ ircd::ctx::ole::init::init()
termination = false;
}
[[gnu::cold]]
ircd::ctx::ole::init::~init()
noexcept
{

View File

@ -138,6 +138,7 @@ catch(const std::exception &e)
throw;
}
[[gnu::cold]]
ircd::db::init::~init()
noexcept
{
@ -1426,7 +1427,7 @@ ircd::db::txn::at(const op &op,
const delta_closure &closure)
const
{
if(!get(op, col, closure))
if(unlikely(!get(op, col, closure)))
throw not_found
{
"db::txn::at(%s, %s): no matching delta in transaction",
@ -1476,7 +1477,7 @@ ircd::db::txn::at(const op &op,
const value_closure &closure)
const
{
if(!get(op, col, key, closure))
if(unlikely(!get(op, col, key, closure)))
throw not_found
{
"db::txn::at(%s, %s, %s): no matching delta in transaction",

View File

@ -2863,6 +2863,7 @@ noexcept
};
}
[[gnu::cold]]
void
ircd::db::database::events::OnBackgroundError(rocksdb::BackgroundErrorReason reason,
rocksdb::Status *const status)

View File

@ -8,13 +8,15 @@
// copyright notice and this permission notice is present in all copies. The
// full license for this software is available in the LICENSE file.
[[noreturn]] static void
[[noreturn, gnu::cold]]
static void
ircd_terminate_handler()
noexcept
{
std::abort();
}
[[gnu::cold]]
void
ircd::_aborting_()
noexcept
@ -22,6 +24,7 @@ noexcept
std::set_terminate(&ircd_terminate_handler);
}
[[gnu::cold]]
void
ircd::panicking(const std::exception_ptr &eptr)
noexcept
@ -35,6 +38,7 @@ noexcept
/// Called by the constructor of a panic exception when thown. We immediately
/// log a critical message, which is actually what triggers a termination when
/// assertions are enabled (!NDEBUG) otherwise a no-op.
[[gnu::cold]]
void
ircd::panicking(const std::exception &e)
noexcept
@ -282,7 +286,7 @@ const noexcept
// terminate
//
[[noreturn]]
[[noreturn, gnu::cold]]
ircd::terminate::terminate(std::exception_ptr eptr)
noexcept
{
@ -292,7 +296,7 @@ noexcept
__builtin_unreachable();
}
[[noreturn]]
[[noreturn, gnu::cold]]
ircd::terminate::terminate(const std::exception &e)
noexcept
:terminate
@ -303,7 +307,7 @@ noexcept
__builtin_unreachable();
}
[[noreturn]]
[[noreturn, gnu::cold]]
ircd::terminate::terminate()
noexcept
:terminate
@ -314,7 +318,7 @@ noexcept
__builtin_unreachable();
}
[[noreturn]]
[[noreturn, gnu::cold]]
ircd::terminate::~terminate()
noexcept
{

View File

@ -12,7 +12,6 @@
#pragma STDC FENV_ACCESS on
#endif
[[gnu::cold]]
void
ircd::fpe::debug_info()
{
@ -68,6 +67,7 @@ ircd::fpe::debug_info()
};
}
[[gnu::cold]]
void
ircd::fpe::_throw_errors(const ushort &flags)
{

View File

@ -60,6 +60,7 @@ ircd::fs::init::init()
init_dump_info();
}
[[gnu::cold]]
ircd::fs::init::~init()
noexcept
{
@ -1646,7 +1647,6 @@ ircd::fs::aio::system;
//
#ifndef IRCD_USE_AIO
[[gnu::weak]]
ircd::fs::aio::init::init()
{
assert(!system);
@ -1654,7 +1654,7 @@ ircd::fs::aio::init::init()
#endif
#ifndef IRCD_USE_AIO
[[gnu::weak]]
[[using gnu: weak, cold]]
ircd::fs::aio::init::~init()
noexcept
{

View File

@ -126,6 +126,7 @@ ircd::fs::aio::init::init()
);
}
[[gnu::cold]]
ircd::fs::aio::init::~init()
noexcept
{

View File

@ -51,6 +51,7 @@ ircd::fs::iou::init::init()
);
}
[[gnu::cold]]
ircd::fs::iou::init::~init()
noexcept
{

View File

@ -42,7 +42,6 @@ ircd::info::credits
nullptr
};
[[gnu::cold]]
void
ircd::info::dump()
{

View File

@ -78,6 +78,7 @@ ircd::ios::init(asio::executor &&user)
ios::main = *ios::primary;
}
[[gnu::cold]]
void
ircd::ios::forking()
{
@ -88,6 +89,7 @@ ircd::ios::forking()
#endif
}
[[gnu::cold]]
void
ircd::ios::forked_child()
{
@ -98,6 +100,7 @@ ircd::ios::forked_child()
#endif
}
[[gnu::cold]]
void
ircd::ios::forked_parent()
{

View File

@ -246,6 +246,7 @@ catch(const std::exception &e)
/// the run() will then return immediately after IRCd posts its transition to
/// the HALT state.
///
[[gnu::cold]]
bool
ircd::quit()
noexcept

View File

@ -595,7 +595,7 @@ noexcept
};
}
[[gnu::noinline]]
[[gnu::noinline, gnu::cold, noreturn]]
void
ircd::json::parser::throws_exceeded()
{
@ -626,7 +626,7 @@ ircd::json::replace(const object &s,
}
};
if(!empty(s) && type(s) != type::OBJECT)
if(unlikely(!empty(s) && type(s) != type::OBJECT))
throw type_error
{
"Cannot replace member into JSON of type %s",
@ -652,7 +652,7 @@ ircd::json::strung
ircd::json::replace(const object &s,
const json::member &m_)
{
if(!empty(s) && type(s) != type::OBJECT)
if(unlikely(!empty(s) && type(s) != type::OBJECT))
throw type_error
{
"Cannot replace member into JSON of type %s",
@ -676,7 +676,7 @@ ircd::json::strung
ircd::json::insert(const object &s,
const json::member &m)
{
if(!empty(s) && type(s) != type::OBJECT)
if(unlikely(!empty(s) && type(s) != type::OBJECT))
throw type_error
{
"Cannot insert member into JSON of type %s",
@ -702,7 +702,7 @@ ircd::json::remove(const object &s,
if(empty(s))
return s;
if(type(s) != type::OBJECT)
if(unlikely(type(s) != type::OBJECT))
throw type_error
{
"Cannot remove object member '%s' from JSON of type %s",
@ -729,7 +729,7 @@ ircd::json::remove(const object &s,
if(empty(s))
return s;
if(type(s) != type::ARRAY)
if(unlikely(type(s) != type::ARRAY))
throw type_error
{
"Cannot remove array element [%zu] from JSON of type %s",

View File

@ -106,6 +106,7 @@ ircd::magic::init::init()
};
}
[[gnu::cold]]
ircd::magic::init::~init()
noexcept
{

View File

@ -248,6 +248,7 @@ ircd::magick::init::init()
};
}
[[gnu::cold]]
ircd::magick::init::~init()
noexcept
{

View File

@ -126,7 +126,7 @@ noexcept
children.size(),
};
if(!mapi::static_destruction)
if(unlikely(!mapi::static_destruction))
{
handle_stuck(mod);
return false;
@ -154,6 +154,7 @@ noexcept
return true;
}
[[gnu::cold]]
void
ircd::mods::handle_stuck(mod &mod)
{
@ -182,6 +183,7 @@ ircd::mods::handle_stuck(mod &mod)
};
}
[[gnu::cold]]
void
ircd::mods::handle_ebadf(const string_view &what)
{

View File

@ -75,6 +75,7 @@ ircd::net::init::init()
}
/// Network subsystem shutdown
[[gnu::cold]]
ircd::net::init::~init()
noexcept
{

View File

@ -42,6 +42,7 @@ ircd::net::dns::init::init()
};
}
[[gnu::cold]]
ircd::net::dns::init::~init()
noexcept
{

View File

@ -47,6 +47,7 @@ ircd::net::dns::init::service_init()
#endif
}
[[gnu::cold]]
void
ircd::net::dns::init::service_fini()
noexcept

View File

@ -1705,6 +1705,7 @@ ircd::openssl::init::init()
*/
}
[[gnu::cold]]
ircd::openssl::init::~init()
noexcept
{

View File

@ -550,6 +550,7 @@ ircd::rfc1035::valid_label(std::nothrow_t,
return rfc3986::valid_hostname(std::nothrow, label);
}
[[gnu::cold]]
std::string
ircd::rfc1035::header::debug()
const

View File

@ -60,6 +60,7 @@ noexcept
{
}
[[gnu::cold]]
ircd::server::init::~init()
noexcept
{