Fixed code after review #3553

This commit is contained in:
Alexey Milovidov 2018-11-14 04:20:46 +03:00
parent 37a9af5a68
commit 1aa89ed63a
2 changed files with 17 additions and 20 deletions

View File

@ -131,27 +131,19 @@ int Server::main(const std::vector<std::string> & /*args*/)
}
const auto memory_amount = getMemoryAmount();
{ /// After full config loaded
#if defined(__linux__)
if (config().getBool("mlock_executable",
false // TODO: uncomment after tests:
/*
#if NDEBUG
memory_amount > 16000000000
? true // Change me to true in future
: false // Dont mlock if we have less than 16G ram
#else
false
#endif
*/
))
/// After full config loaded
{
if (config().getBool("mlock_executable", false))
{
if (hasLinuxCapability(CAP_IPC_LOCK))
{
LOG_TRACE(log, "Will mlockall to prevent executable memory from being paged out. It may take a few seconds.");
if (0 != mlockall(MCL_CURRENT))
LOG_WARNING(log, "Failed mlockall: " + errnoToString());
else
LOG_TRACE(log, "Binary mlock'ed");
LOG_TRACE(log, "The memory map of clickhouse executable has been mlock'ed");
}
else
{
@ -159,11 +151,10 @@ int Server::main(const std::vector<std::string> & /*args*/)
" It could happen due to incorrect ClickHouse package installation."
" You could resolve the problem manually with 'sudo setcap cap_ipc_lock=+ep /usr/bin/clickhouse'."
" Note that it will not work on 'nosuid' mounted filesystems.");
}
}
}
#endif
}
std::string path = getCanonicalPath(config().getString("path"));
std::string default_database = config().getString("default_database", "default");

View File

@ -145,6 +145,12 @@
-->
<!-- <umask>022</umask> -->
<!-- Perform mlockall after startup to lower first queries latency
and to prevent clickhouse executable from being paged out under high IO load.
Enabling this option is recommended but will lead to increased startup time for up to a few seconds.
-->
<mlock_executable>false</mlock_executable>
<!-- Configuration of clusters that could be used in Distributed tables.
https://clickhouse.yandex/docs/en/table_engines/distributed/
-->