From 6045c90bf00c8c1fe22df783e5ba36ecd4834a77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Wed, 17 Oct 2018 10:15:14 +0300 Subject: [PATCH] Log query classifier cache size on startup --- server/core/config.cc | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/server/core/config.cc b/server/core/config.cc index 305fb7161..06a6538d3 100644 --- a/server/core/config.cc +++ b/server/core/config.cc @@ -1224,6 +1224,29 @@ bool config_load_global(const char* filename) "cache. Manually define `%s` to enable it.", CN_QUERY_CLASSIFIER_CACHE_SIZE); } + else + { + std::vector suffixes + { + "B", + "KiB", + "MiB", + "GiB", + "TiB", + "PiB", + "EiB", + "ZiB", + "YiB" + }; + // Get the total used cache memory + int64_t total_mem = mem_per_thr * gateway.n_threads; + // Calculate log1024(total_mem) and round it up + double c = ceil(log(total_mem) / log(1024)); + // In case someone still uses MaxScale in the year 3054 + int idx = std::min(c, (double)(suffixes.size())) - 1; + double num = total_mem / pow(1024, idx); + MXS_NOTICE("Using up to %.2lf%s of memory for query classifier cache", num, suffixes[idx]); + } } }