mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
Cleanup #4240
This commit is contained in:
parent
dc863dd8a0
commit
eb39f6b653
@ -435,39 +435,37 @@ int Server::main(const std::vector<std::string> & /*args*/)
|
||||
if (config().has("max_partition_size_to_drop"))
|
||||
global_context->setMaxPartitionSizeToDrop(config().getUInt64("max_partition_size_to_drop"));
|
||||
|
||||
const auto cache_reduce_coef = 0.5;
|
||||
/// Set up caches.
|
||||
|
||||
/// Lower cache size on low-memory systems.
|
||||
double cache_size_to_ram_max_ratio = config().getDouble("cache_size_to_ram_max_ratio", 0.5);
|
||||
size_t max_cache_size = memory_amount * cache_size_to_ram_max_ratio;
|
||||
|
||||
/// Size of cache for uncompressed blocks. Zero means disabled.
|
||||
size_t uncompressed_cache_size = config().getUInt64("uncompressed_cache_size", 0);
|
||||
size_t recommended_uncompressed_cache_size = cache_reduce_coef * memory_amount;
|
||||
if (recommended_uncompressed_cache_size < uncompressed_cache_size)
|
||||
if (uncompressed_cache_size > max_cache_size)
|
||||
{
|
||||
LOG_WARNING(log, "Uncompressed cache size is set automatically: ");
|
||||
LOG_WARNING(log, recommended_uncompressed_cache_size);
|
||||
global_context->setUncompressedCache(recommended_uncompressed_cache_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
global_context->setUncompressedCache(uncompressed_cache_size);
|
||||
uncompressed_cache_size = max_cache_size;
|
||||
LOG_INFO(log, "Uncompressed cache size was lowered to " << formatReadableSizeWithBinarySuffix(uncompressed_cache_size)
|
||||
<< " because the system has low amount of memory");
|
||||
}
|
||||
global_context->setUncompressedCache(uncompressed_cache_size);
|
||||
|
||||
/// Load global settings from default_profile and system_profile.
|
||||
global_context->setDefaultProfiles(config());
|
||||
Settings & settings = global_context->getSettingsRef();
|
||||
|
||||
/// Size of cache for marks (index of MergeTree family of tables). It is necessary.
|
||||
/// Size of cache for marks (index of MergeTree family of tables). It is mandatory.
|
||||
size_t mark_cache_size = config().getUInt64("mark_cache_size");
|
||||
size_t recommended_mark_cache_size = cache_reduce_coef * memory_amount;
|
||||
if (recommended_mark_cache_size < mark_cache_size
|
||||
|| mark_cache_size == 0)
|
||||
if (!mark_cache_size)
|
||||
LOG_ERROR(log, "Too low mark cache size will lead to severe performance degradation.");
|
||||
if (mark_cache_size > max_cache_size)
|
||||
{
|
||||
LOG_WARNING(log, "Mark cache size is set automatically: ");
|
||||
LOG_WARNING(log, recommended_mark_cache_size);
|
||||
global_context->setMarkCache(recommended_mark_cache_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
global_context->setMarkCache(mark_cache_size);
|
||||
mark_cache_size = max_cache_size;
|
||||
LOG_INFO(log, "Mark cache size was lowered to " << formatReadableSizeWithBinarySuffix(uncompressed_cache_size)
|
||||
<< " because the system has low amount of memory");
|
||||
}
|
||||
global_context->setMarkCache(mark_cache_size);
|
||||
|
||||
#if USE_EMBEDDED_COMPILER
|
||||
size_t compiled_expression_cache_size = config().getUInt64("compiled_expression_cache_size", 500);
|
||||
@ -754,10 +752,10 @@ int Server::main(const std::vector<std::string> & /*args*/)
|
||||
|
||||
{
|
||||
std::stringstream message;
|
||||
message << "Available RAM = " << formatReadableSizeWithBinarySuffix(memory_amount) << ";"
|
||||
<< " physical cores = " << getNumberOfPhysicalCPUCores() << ";"
|
||||
message << "Available RAM: " << formatReadableSizeWithBinarySuffix(memory_amount) << ";"
|
||||
<< " physical cores: " << getNumberOfPhysicalCPUCores() << ";"
|
||||
// on ARM processors it can show only enabled at current moment cores
|
||||
<< " threads = " << std::thread::hardware_concurrency() << ".";
|
||||
<< " logical cores: " << std::thread::hardware_concurrency() << ".";
|
||||
LOG_INFO(log, message.str());
|
||||
}
|
||||
|
||||
|
@ -2,8 +2,11 @@
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
/**
|
||||
* Returns the size of physical memory (RAM) in bytes.
|
||||
* Returns 0 on unsupported platform
|
||||
*/
|
||||
/** Returns the size of physical memory (RAM) in bytes.
|
||||
* Returns 0 on unsupported platform or if it cannot determine the size of physical memory.
|
||||
*/
|
||||
uint64_t getMemoryAmountOrZero();
|
||||
|
||||
/** Throws exception if it cannot determine the size of physical memory.
|
||||
*/
|
||||
uint64_t getMemoryAmount();
|
||||
|
@ -1,3 +1,4 @@
|
||||
#include <stdexcept>
|
||||
#include "common/getMemoryAmount.h"
|
||||
|
||||
// http://nadeausoftware.com/articles/2012/09/c_c_tip_how_get_physical_memory_size_system
|
||||
@ -25,7 +26,7 @@
|
||||
* Returns the size of physical memory (RAM) in bytes.
|
||||
* Returns 0 on unsupported platform
|
||||
*/
|
||||
uint64_t getMemoryAmount()
|
||||
uint64_t getMemoryAmountOrZero()
|
||||
{
|
||||
#if defined(_WIN32) && (defined(__CYGWIN__) || defined(__CYGWIN32__))
|
||||
/* Cygwin under Windows. ------------------------------------ */
|
||||
@ -95,3 +96,12 @@ uint64_t getMemoryAmount()
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
uint64_t getMemoryAmount()
|
||||
{
|
||||
auto res = getMemoryAmountOrZero();
|
||||
if (!res)
|
||||
throw std::runtime_error("Cannot determine memory amount");
|
||||
return res;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user