summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--searchcore/src/tests/proton/server/memory_flush_config_updater/memory_flush_config_updater_test.cpp24
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/memory_flush_config_updater.cpp13
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/indexflushtarget.h23
3 files changed, 41 insertions, 19 deletions
diff --git a/searchcore/src/tests/proton/server/memory_flush_config_updater/memory_flush_config_updater_test.cpp b/searchcore/src/tests/proton/server/memory_flush_config_updater/memory_flush_config_updater_test.cpp
index 716b369d928..ff64d614169 100644
--- a/searchcore/src/tests/proton/server/memory_flush_config_updater/memory_flush_config_updater_test.cpp
+++ b/searchcore/src/tests/proton/server/memory_flush_config_updater/memory_flush_config_updater_test.cpp
@@ -42,6 +42,7 @@ belowLimit()
}
const HwInfo::Memory defaultMemory(8ul * 1024ul * 1024ul * 1024ul);
+constexpr size_t ONE_G = 1024ul * 1024ul * 1024ul;;
struct Fixture
{
@@ -74,6 +75,29 @@ TEST_F("require that strategy is updated when setting new config", Fixture)
TEST_DO(f.assertStrategyConfig(6, 3, 30));
}
+TEST("require that we use configured memory limits") {
+ auto cfg = MemoryFlushConfigUpdater::convertConfig(getConfig(6, 3, 30), defaultMemory);
+ EXPECT_EQUAL(cfg.maxGlobalMemory, 6u);
+ EXPECT_EQUAL(cfg.maxMemoryGain, 3);
+}
+
+TEST("require that we cap configured limits based on available memory") {
+ const uint64_t LIMIT = defaultMemory.sizeBytes()/4;
+ constexpr uint64_t MEM_4G = 4 * ONE_G;
+ auto cfg = MemoryFlushConfigUpdater::convertConfig(getConfig(MEM_4G, MEM_4G, 30), defaultMemory);
+ EXPECT_EQUAL(cfg.maxGlobalMemory, LIMIT);
+ EXPECT_EQUAL(uint64_t(cfg.maxMemoryGain), LIMIT);
+}
+
+TEST("require that we cap configured limits based on the absolute 16G limit") {
+ constexpr uint64_t LIMIT_16G = 16 * ONE_G;
+ constexpr uint64_t MEM_64G = 64 * ONE_G;
+ const HwInfo::Memory largeMemory(512 * ONE_G);
+ auto cfg = MemoryFlushConfigUpdater::convertConfig(getConfig(MEM_64G, MEM_64G, 30), largeMemory);
+ EXPECT_EQUAL(cfg.maxGlobalMemory, LIMIT_16G);
+ EXPECT_EQUAL(uint64_t(cfg.maxMemoryGain), LIMIT_16G);
+}
+
TEST_F("require that strategy is updated with normal values if no limits are reached", Fixture)
{
f.updater.notifyDiskMemUsage(DiskMemUsageState());
diff --git a/searchcore/src/vespa/searchcore/proton/server/memory_flush_config_updater.cpp b/searchcore/src/vespa/searchcore/proton/server/memory_flush_config_updater.cpp
index c67a43e9edd..f2d45c996ae 100644
--- a/searchcore/src/vespa/searchcore/proton/server/memory_flush_config_updater.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/memory_flush_config_updater.cpp
@@ -111,12 +111,15 @@ MemoryFlushConfigUpdater::setNodeRetired(bool nodeRetired)
}
namespace {
+// This is a hard limit to ensure that we stop before we reach some internal limits.
+// This responsibility should not be here, but in each of the components
+
+constexpr uint64_t MAX_HARD_MEMORY_LIMIT_16G = 16ul * 1024ul * 1024ul * 1024ul;
size_t
getHardMemoryLimit(const HwInfo::Memory &memory)
{
- return std::max((size_t) memory.sizeBytes() / 4,
- (size_t) 16ul * 1024ul * 1024ul * 1024ul);
+ return std::min(memory.sizeBytes() / 4, MAX_HARD_MEMORY_LIMIT_16G);
}
}
@@ -130,16 +133,14 @@ MemoryFlushConfigUpdater::convertConfig(const ProtonConfig::Flush::Memory &confi
if (totalMaxMemory > hardMemoryLimit) {
LOG(info, "flush.memory.maxmemory=%" PRId64 " cannot"
" be set above the hard limit of %ld so we cap it to the hard limit",
- config.maxmemory,
- hardMemoryLimit);
+ config.maxmemory, hardMemoryLimit);
totalMaxMemory = hardMemoryLimit;
}
size_t eachMaxMemory = config.each.maxmemory;
if (eachMaxMemory > hardMemoryLimit) {
LOG(info, "flush.memory.each.maxmemory=%" PRId64 " cannot"
" be set above the hard limit of %ld so we cap it to the hard limit",
- config.maxmemory,
- hardMemoryLimit);
+ config.maxmemory, hardMemoryLimit);
eachMaxMemory = hardMemoryLimit;
}
return MemoryFlush::Config(totalMaxMemory,
diff --git a/searchcorespi/src/vespa/searchcorespi/index/indexflushtarget.h b/searchcorespi/src/vespa/searchcorespi/index/indexflushtarget.h
index 50ae2000a11..5573a646d1b 100644
--- a/searchcorespi/src/vespa/searchcorespi/index/indexflushtarget.h
+++ b/searchcorespi/src/vespa/searchcorespi/index/indexflushtarget.h
@@ -4,8 +4,7 @@
#include "indexmaintainer.h"
#include <vespa/searchcorespi/flush/iflushtarget.h>
-namespace searchcorespi {
-namespace index {
+namespace searchcorespi::index {
/**
* Flush target for flushing a memory index in an IndexMaintainer.
@@ -23,18 +22,16 @@ public:
~IndexFlushTarget();
// Implements IFlushTarget
- virtual MemoryGain getApproxMemoryGain() const override;
- virtual DiskGain getApproxDiskGain() const override;
- virtual SerialNum getFlushedSerialNum() const override;
- virtual Time getLastFlushTime() const override;
+ MemoryGain getApproxMemoryGain() const override;
+ DiskGain getApproxDiskGain() const override;
+ SerialNum getFlushedSerialNum() const override;
+ Time getLastFlushTime() const override;
- virtual bool needUrgentFlush() const override;
+ bool needUrgentFlush() const override;
- virtual Task::UP initFlush(SerialNum currentSerial, std::shared_ptr<search::IFlushToken> flush_token) override;
- virtual FlushStats getLastFlushStats() const override { return _lastStats; }
- virtual uint64_t getApproxBytesToWriteToDisk() const override;
+ Task::UP initFlush(SerialNum currentSerial, std::shared_ptr<search::IFlushToken> flush_token) override;
+ FlushStats getLastFlushStats() const override { return _lastStats; }
+ uint64_t getApproxBytesToWriteToDisk() const override;
};
-} // namespace index
-} // namespace searchcorespi
-
+}