mirror of
https://github.com/matrix-construct/construct
synced 2024-05-19 19:33:45 +02:00
ircd: Toward improving cold/unlikely section population.
This commit is contained in:
parent
f5d3da8d3f
commit
04558290c0
|
@ -30,7 +30,7 @@ struct name \
|
||||||
:parent \
|
:parent \
|
||||||
{ \
|
{ \
|
||||||
template<class... args> \
|
template<class... args> \
|
||||||
[[gnu::noinline]] \
|
[[gnu::noinline, gnu::cold]] \
|
||||||
name(const string_view &fmt, args&&... ap) noexcept \
|
name(const string_view &fmt, args&&... ap) noexcept \
|
||||||
:parent{generate_skip} \
|
:parent{generate_skip} \
|
||||||
{ \
|
{ \
|
||||||
|
@ -39,7 +39,7 @@ struct name \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
template<class... args> \
|
template<class... args> \
|
||||||
[[gnu::noinline]] \
|
[[gnu::noinline, gnu::cold]] \
|
||||||
name(const string_view &fmt = " ") noexcept \
|
name(const string_view &fmt = " ") noexcept \
|
||||||
:parent{generate_skip} \
|
:parent{generate_skip} \
|
||||||
{ \
|
{ \
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#pragma clang diagnostic push
|
#pragma clang diagnostic push
|
||||||
#pragma clang diagnostic ignored "-Wunreachable-code"
|
#pragma clang diagnostic ignored "-Wunreachable-code"
|
||||||
#endif __clang__
|
#endif __clang__
|
||||||
|
[[gnu::cold]]
|
||||||
void
|
void
|
||||||
__assert_fail(const char *__assertion,
|
__assert_fail(const char *__assertion,
|
||||||
const char *__file,
|
const char *__file,
|
||||||
|
@ -70,6 +71,7 @@ __assert_fail(const char *__assertion,
|
||||||
#endif __clang__
|
#endif __clang__
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
[[gnu::cold]]
|
||||||
void
|
void
|
||||||
ircd::print_assertion(const char *const __assertion,
|
ircd::print_assertion(const char *const __assertion,
|
||||||
const char *const __file,
|
const char *const __file,
|
||||||
|
|
|
@ -253,6 +253,7 @@ ircd::cl::init::init()
|
||||||
log_dev_info();
|
log_dev_info();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[gnu::cold]]
|
||||||
ircd::cl::init::~init()
|
ircd::cl::init::~init()
|
||||||
noexcept
|
noexcept
|
||||||
{
|
{
|
||||||
|
|
|
@ -127,6 +127,7 @@ ircd::client::init::init()
|
||||||
spawn();
|
spawn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[gnu::cold]]
|
||||||
ircd::client::init::~init()
|
ircd::client::init::~init()
|
||||||
noexcept
|
noexcept
|
||||||
{
|
{
|
||||||
|
|
|
@ -884,6 +884,7 @@ noexcept
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
[[gnu::cold]]
|
||||||
void
|
void
|
||||||
ircd::ctx::assert_critical()
|
ircd::ctx::assert_critical()
|
||||||
{
|
{
|
||||||
|
|
|
@ -40,6 +40,7 @@ ircd::ctx::ole::init::init()
|
||||||
termination = false;
|
termination = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[gnu::cold]]
|
||||||
ircd::ctx::ole::init::~init()
|
ircd::ctx::ole::init::~init()
|
||||||
noexcept
|
noexcept
|
||||||
{
|
{
|
||||||
|
|
|
@ -138,6 +138,7 @@ catch(const std::exception &e)
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[gnu::cold]]
|
||||||
ircd::db::init::~init()
|
ircd::db::init::~init()
|
||||||
noexcept
|
noexcept
|
||||||
{
|
{
|
||||||
|
@ -1426,7 +1427,7 @@ ircd::db::txn::at(const op &op,
|
||||||
const delta_closure &closure)
|
const delta_closure &closure)
|
||||||
const
|
const
|
||||||
{
|
{
|
||||||
if(!get(op, col, closure))
|
if(unlikely(!get(op, col, closure)))
|
||||||
throw not_found
|
throw not_found
|
||||||
{
|
{
|
||||||
"db::txn::at(%s, %s): no matching delta in transaction",
|
"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 value_closure &closure)
|
||||||
const
|
const
|
||||||
{
|
{
|
||||||
if(!get(op, col, key, closure))
|
if(unlikely(!get(op, col, key, closure)))
|
||||||
throw not_found
|
throw not_found
|
||||||
{
|
{
|
||||||
"db::txn::at(%s, %s, %s): no matching delta in transaction",
|
"db::txn::at(%s, %s, %s): no matching delta in transaction",
|
||||||
|
|
|
@ -2863,6 +2863,7 @@ noexcept
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[gnu::cold]]
|
||||||
void
|
void
|
||||||
ircd::db::database::events::OnBackgroundError(rocksdb::BackgroundErrorReason reason,
|
ircd::db::database::events::OnBackgroundError(rocksdb::BackgroundErrorReason reason,
|
||||||
rocksdb::Status *const status)
|
rocksdb::Status *const status)
|
||||||
|
|
|
@ -8,13 +8,15 @@
|
||||||
// copyright notice and this permission notice is present in all copies. The
|
// copyright notice and this permission notice is present in all copies. The
|
||||||
// full license for this software is available in the LICENSE file.
|
// full license for this software is available in the LICENSE file.
|
||||||
|
|
||||||
[[noreturn]] static void
|
[[noreturn, gnu::cold]]
|
||||||
|
static void
|
||||||
ircd_terminate_handler()
|
ircd_terminate_handler()
|
||||||
noexcept
|
noexcept
|
||||||
{
|
{
|
||||||
std::abort();
|
std::abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[gnu::cold]]
|
||||||
void
|
void
|
||||||
ircd::_aborting_()
|
ircd::_aborting_()
|
||||||
noexcept
|
noexcept
|
||||||
|
@ -22,6 +24,7 @@ noexcept
|
||||||
std::set_terminate(&ircd_terminate_handler);
|
std::set_terminate(&ircd_terminate_handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[gnu::cold]]
|
||||||
void
|
void
|
||||||
ircd::panicking(const std::exception_ptr &eptr)
|
ircd::panicking(const std::exception_ptr &eptr)
|
||||||
noexcept
|
noexcept
|
||||||
|
@ -35,6 +38,7 @@ noexcept
|
||||||
/// Called by the constructor of a panic exception when thown. We immediately
|
/// Called by the constructor of a panic exception when thown. We immediately
|
||||||
/// log a critical message, which is actually what triggers a termination when
|
/// log a critical message, which is actually what triggers a termination when
|
||||||
/// assertions are enabled (!NDEBUG) otherwise a no-op.
|
/// assertions are enabled (!NDEBUG) otherwise a no-op.
|
||||||
|
[[gnu::cold]]
|
||||||
void
|
void
|
||||||
ircd::panicking(const std::exception &e)
|
ircd::panicking(const std::exception &e)
|
||||||
noexcept
|
noexcept
|
||||||
|
@ -282,7 +286,7 @@ const noexcept
|
||||||
// terminate
|
// terminate
|
||||||
//
|
//
|
||||||
|
|
||||||
[[noreturn]]
|
[[noreturn, gnu::cold]]
|
||||||
ircd::terminate::terminate(std::exception_ptr eptr)
|
ircd::terminate::terminate(std::exception_ptr eptr)
|
||||||
noexcept
|
noexcept
|
||||||
{
|
{
|
||||||
|
@ -292,7 +296,7 @@ noexcept
|
||||||
__builtin_unreachable();
|
__builtin_unreachable();
|
||||||
}
|
}
|
||||||
|
|
||||||
[[noreturn]]
|
[[noreturn, gnu::cold]]
|
||||||
ircd::terminate::terminate(const std::exception &e)
|
ircd::terminate::terminate(const std::exception &e)
|
||||||
noexcept
|
noexcept
|
||||||
:terminate
|
:terminate
|
||||||
|
@ -303,7 +307,7 @@ noexcept
|
||||||
__builtin_unreachable();
|
__builtin_unreachable();
|
||||||
}
|
}
|
||||||
|
|
||||||
[[noreturn]]
|
[[noreturn, gnu::cold]]
|
||||||
ircd::terminate::terminate()
|
ircd::terminate::terminate()
|
||||||
noexcept
|
noexcept
|
||||||
:terminate
|
:terminate
|
||||||
|
@ -314,7 +318,7 @@ noexcept
|
||||||
__builtin_unreachable();
|
__builtin_unreachable();
|
||||||
}
|
}
|
||||||
|
|
||||||
[[noreturn]]
|
[[noreturn, gnu::cold]]
|
||||||
ircd::terminate::~terminate()
|
ircd::terminate::~terminate()
|
||||||
noexcept
|
noexcept
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
#pragma STDC FENV_ACCESS on
|
#pragma STDC FENV_ACCESS on
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
[[gnu::cold]]
|
|
||||||
void
|
void
|
||||||
ircd::fpe::debug_info()
|
ircd::fpe::debug_info()
|
||||||
{
|
{
|
||||||
|
@ -68,6 +67,7 @@ ircd::fpe::debug_info()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[gnu::cold]]
|
||||||
void
|
void
|
||||||
ircd::fpe::_throw_errors(const ushort &flags)
|
ircd::fpe::_throw_errors(const ushort &flags)
|
||||||
{
|
{
|
||||||
|
|
|
@ -60,6 +60,7 @@ ircd::fs::init::init()
|
||||||
init_dump_info();
|
init_dump_info();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[gnu::cold]]
|
||||||
ircd::fs::init::~init()
|
ircd::fs::init::~init()
|
||||||
noexcept
|
noexcept
|
||||||
{
|
{
|
||||||
|
@ -1646,7 +1647,6 @@ ircd::fs::aio::system;
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef IRCD_USE_AIO
|
#ifndef IRCD_USE_AIO
|
||||||
[[gnu::weak]]
|
|
||||||
ircd::fs::aio::init::init()
|
ircd::fs::aio::init::init()
|
||||||
{
|
{
|
||||||
assert(!system);
|
assert(!system);
|
||||||
|
@ -1654,7 +1654,7 @@ ircd::fs::aio::init::init()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef IRCD_USE_AIO
|
#ifndef IRCD_USE_AIO
|
||||||
[[gnu::weak]]
|
[[using gnu: weak, cold]]
|
||||||
ircd::fs::aio::init::~init()
|
ircd::fs::aio::init::~init()
|
||||||
noexcept
|
noexcept
|
||||||
{
|
{
|
||||||
|
|
|
@ -126,6 +126,7 @@ ircd::fs::aio::init::init()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[gnu::cold]]
|
||||||
ircd::fs::aio::init::~init()
|
ircd::fs::aio::init::~init()
|
||||||
noexcept
|
noexcept
|
||||||
{
|
{
|
||||||
|
|
|
@ -51,6 +51,7 @@ ircd::fs::iou::init::init()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[gnu::cold]]
|
||||||
ircd::fs::iou::init::~init()
|
ircd::fs::iou::init::~init()
|
||||||
noexcept
|
noexcept
|
||||||
{
|
{
|
||||||
|
|
|
@ -42,7 +42,6 @@ ircd::info::credits
|
||||||
nullptr
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
[[gnu::cold]]
|
|
||||||
void
|
void
|
||||||
ircd::info::dump()
|
ircd::info::dump()
|
||||||
{
|
{
|
||||||
|
|
|
@ -78,6 +78,7 @@ ircd::ios::init(asio::executor &&user)
|
||||||
ios::main = *ios::primary;
|
ios::main = *ios::primary;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[gnu::cold]]
|
||||||
void
|
void
|
||||||
ircd::ios::forking()
|
ircd::ios::forking()
|
||||||
{
|
{
|
||||||
|
@ -88,6 +89,7 @@ ircd::ios::forking()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[gnu::cold]]
|
||||||
void
|
void
|
||||||
ircd::ios::forked_child()
|
ircd::ios::forked_child()
|
||||||
{
|
{
|
||||||
|
@ -98,6 +100,7 @@ ircd::ios::forked_child()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[gnu::cold]]
|
||||||
void
|
void
|
||||||
ircd::ios::forked_parent()
|
ircd::ios::forked_parent()
|
||||||
{
|
{
|
||||||
|
|
|
@ -246,6 +246,7 @@ catch(const std::exception &e)
|
||||||
/// the run() will then return immediately after IRCd posts its transition to
|
/// the run() will then return immediately after IRCd posts its transition to
|
||||||
/// the HALT state.
|
/// the HALT state.
|
||||||
///
|
///
|
||||||
|
[[gnu::cold]]
|
||||||
bool
|
bool
|
||||||
ircd::quit()
|
ircd::quit()
|
||||||
noexcept
|
noexcept
|
||||||
|
|
12
ircd/json.cc
12
ircd/json.cc
|
@ -595,7 +595,7 @@ noexcept
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
[[gnu::noinline]]
|
[[gnu::noinline, gnu::cold, noreturn]]
|
||||||
void
|
void
|
||||||
ircd::json::parser::throws_exceeded()
|
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
|
throw type_error
|
||||||
{
|
{
|
||||||
"Cannot replace member into JSON of type %s",
|
"Cannot replace member into JSON of type %s",
|
||||||
|
@ -652,7 +652,7 @@ ircd::json::strung
|
||||||
ircd::json::replace(const object &s,
|
ircd::json::replace(const object &s,
|
||||||
const json::member &m_)
|
const json::member &m_)
|
||||||
{
|
{
|
||||||
if(!empty(s) && type(s) != type::OBJECT)
|
if(unlikely(!empty(s) && type(s) != type::OBJECT))
|
||||||
throw type_error
|
throw type_error
|
||||||
{
|
{
|
||||||
"Cannot replace member into JSON of type %s",
|
"Cannot replace member into JSON of type %s",
|
||||||
|
@ -676,7 +676,7 @@ ircd::json::strung
|
||||||
ircd::json::insert(const object &s,
|
ircd::json::insert(const object &s,
|
||||||
const json::member &m)
|
const json::member &m)
|
||||||
{
|
{
|
||||||
if(!empty(s) && type(s) != type::OBJECT)
|
if(unlikely(!empty(s) && type(s) != type::OBJECT))
|
||||||
throw type_error
|
throw type_error
|
||||||
{
|
{
|
||||||
"Cannot insert member into JSON of type %s",
|
"Cannot insert member into JSON of type %s",
|
||||||
|
@ -702,7 +702,7 @@ ircd::json::remove(const object &s,
|
||||||
if(empty(s))
|
if(empty(s))
|
||||||
return s;
|
return s;
|
||||||
|
|
||||||
if(type(s) != type::OBJECT)
|
if(unlikely(type(s) != type::OBJECT))
|
||||||
throw type_error
|
throw type_error
|
||||||
{
|
{
|
||||||
"Cannot remove object member '%s' from JSON of type %s",
|
"Cannot remove object member '%s' from JSON of type %s",
|
||||||
|
@ -729,7 +729,7 @@ ircd::json::remove(const object &s,
|
||||||
if(empty(s))
|
if(empty(s))
|
||||||
return s;
|
return s;
|
||||||
|
|
||||||
if(type(s) != type::ARRAY)
|
if(unlikely(type(s) != type::ARRAY))
|
||||||
throw type_error
|
throw type_error
|
||||||
{
|
{
|
||||||
"Cannot remove array element [%zu] from JSON of type %s",
|
"Cannot remove array element [%zu] from JSON of type %s",
|
||||||
|
|
|
@ -106,6 +106,7 @@ ircd::magic::init::init()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[gnu::cold]]
|
||||||
ircd::magic::init::~init()
|
ircd::magic::init::~init()
|
||||||
noexcept
|
noexcept
|
||||||
{
|
{
|
||||||
|
|
|
@ -248,6 +248,7 @@ ircd::magick::init::init()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[gnu::cold]]
|
||||||
ircd::magick::init::~init()
|
ircd::magick::init::~init()
|
||||||
noexcept
|
noexcept
|
||||||
{
|
{
|
||||||
|
|
|
@ -126,7 +126,7 @@ noexcept
|
||||||
children.size(),
|
children.size(),
|
||||||
};
|
};
|
||||||
|
|
||||||
if(!mapi::static_destruction)
|
if(unlikely(!mapi::static_destruction))
|
||||||
{
|
{
|
||||||
handle_stuck(mod);
|
handle_stuck(mod);
|
||||||
return false;
|
return false;
|
||||||
|
@ -154,6 +154,7 @@ noexcept
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[gnu::cold]]
|
||||||
void
|
void
|
||||||
ircd::mods::handle_stuck(mod &mod)
|
ircd::mods::handle_stuck(mod &mod)
|
||||||
{
|
{
|
||||||
|
@ -182,6 +183,7 @@ ircd::mods::handle_stuck(mod &mod)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[gnu::cold]]
|
||||||
void
|
void
|
||||||
ircd::mods::handle_ebadf(const string_view &what)
|
ircd::mods::handle_ebadf(const string_view &what)
|
||||||
{
|
{
|
||||||
|
|
|
@ -75,6 +75,7 @@ ircd::net::init::init()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Network subsystem shutdown
|
/// Network subsystem shutdown
|
||||||
|
[[gnu::cold]]
|
||||||
ircd::net::init::~init()
|
ircd::net::init::~init()
|
||||||
noexcept
|
noexcept
|
||||||
{
|
{
|
||||||
|
|
|
@ -42,6 +42,7 @@ ircd::net::dns::init::init()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[gnu::cold]]
|
||||||
ircd::net::dns::init::~init()
|
ircd::net::dns::init::~init()
|
||||||
noexcept
|
noexcept
|
||||||
{
|
{
|
||||||
|
|
|
@ -47,6 +47,7 @@ ircd::net::dns::init::service_init()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[gnu::cold]]
|
||||||
void
|
void
|
||||||
ircd::net::dns::init::service_fini()
|
ircd::net::dns::init::service_fini()
|
||||||
noexcept
|
noexcept
|
||||||
|
|
|
@ -1705,6 +1705,7 @@ ircd::openssl::init::init()
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[gnu::cold]]
|
||||||
ircd::openssl::init::~init()
|
ircd::openssl::init::~init()
|
||||||
noexcept
|
noexcept
|
||||||
{
|
{
|
||||||
|
|
|
@ -550,6 +550,7 @@ ircd::rfc1035::valid_label(std::nothrow_t,
|
||||||
return rfc3986::valid_hostname(std::nothrow, label);
|
return rfc3986::valid_hostname(std::nothrow, label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[gnu::cold]]
|
||||||
std::string
|
std::string
|
||||||
ircd::rfc1035::header::debug()
|
ircd::rfc1035::header::debug()
|
||||||
const
|
const
|
||||||
|
|
|
@ -60,6 +60,7 @@ noexcept
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[gnu::cold]]
|
||||||
ircd::server::init::~init()
|
ircd::server::init::~init()
|
||||||
noexcept
|
noexcept
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue