summaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorGeir Storli <geirst@oath.com>2017-10-26 08:47:53 +0000
committerGeir Storli <geirst@oath.com>2017-10-26 08:47:53 +0000
commit07404c32fbb27aecfcd12243019dad7f9c69e97b (patch)
tree7742bced8ab44811535ad69bb63e0c6b92ca3dcb /searchcore
parentaaf723cf428b95cade93a8144c42152a508df31e (diff)
Adjust hard memory limits for flush strategy.
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/tests/proton/server/memory_flush_config_updater/memory_flush_config_updater_test.cpp6
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/memory_flush_config_updater.cpp35
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/memory_flush_config_updater.h8
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/proton.cpp4
4 files changed, 34 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 7a52e5dce4b..a76596aa927 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
@@ -41,13 +41,15 @@ belowLimit()
return ResourceUsageState(0.7, 0.6);
}
+const HwInfo::Memory defaultMemory(8ul * 1024ul * 1024ul * 1024ul);
+
struct Fixture
{
MemoryFlush::SP strategy;
MemoryFlushConfigUpdater updater;
Fixture()
- : strategy(std::make_shared<MemoryFlush>(MemoryFlushConfigUpdater::convertConfig(getDefaultConfig()))),
- updater(strategy, getDefaultConfig())
+ : strategy(std::make_shared<MemoryFlush>(MemoryFlushConfigUpdater::convertConfig(getDefaultConfig(), defaultMemory))),
+ updater(strategy, getDefaultConfig(), defaultMemory)
{}
void assertStrategyConfig(uint64_t expMaxGlobalMemory, int64_t expMaxEachMemory, uint64_t expMaxGlobalTlsSize) {
EXPECT_EQUAL(expMaxGlobalMemory, strategy->getConfig().maxGlobalMemory);
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 954035ecbb1..a5b0df67b77 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
@@ -2,6 +2,7 @@
#include "memory_flush_config_updater.h"
#include <vespa/log/log.h>
+
LOG_SETUP(".proton.server.memory_flush_config_updater");
namespace proton {
@@ -50,17 +51,19 @@ MemoryFlushConfigUpdater::considerUseConservativeMemoryMode(const LockGuard &,
void
MemoryFlushConfigUpdater::updateFlushStrategy(const LockGuard &guard)
{
- MemoryFlush::Config newConfig = convertConfig(_currConfig);
+ MemoryFlush::Config newConfig = convertConfig(_currConfig, _memory);
considerUseConservativeDiskMode(guard, newConfig);
considerUseConservativeMemoryMode(guard, newConfig);
_flushStrategy->setConfig(newConfig);
}
MemoryFlushConfigUpdater::MemoryFlushConfigUpdater(const MemoryFlush::SP &flushStrategy,
- const ProtonConfig::Flush::Memory &config)
+ const ProtonConfig::Flush::Memory &config,
+ const HwInfo::Memory &memory)
: _mutex(),
_flushStrategy(flushStrategy),
_currConfig(config),
+ _memory(memory),
_currState(),
_useConservativeDiskMode(false),
_useConservativeMemoryMode(false)
@@ -85,29 +88,35 @@ MemoryFlushConfigUpdater::notifyDiskMemUsage(DiskMemUsageState newState)
namespace {
-static constexpr size_t TOTAL_HARD_MEMORY_LIMIT = 16 * 1024 * 1024 * 1024ul;
-static constexpr size_t EACH_HARD_MEMORY_LIMIT = 12 * 1024 * 1024 * 1024ul;
+size_t
+getHardMemoryLimit(const HwInfo::Memory &memory)
+{
+ return std::max((size_t) memory.sizeBytes() / 4,
+ (size_t) 16ul * 1024ul * 1024ul * 1024ul);
+}
}
MemoryFlush::Config
-MemoryFlushConfigUpdater::convertConfig(const ProtonConfig::Flush::Memory &config)
+MemoryFlushConfigUpdater::convertConfig(const ProtonConfig::Flush::Memory &config,
+ const HwInfo::Memory &memory)
{
+ const size_t hardMemoryLimit = getHardMemoryLimit(memory);
size_t totalMaxMemory = config.maxmemory;
- if (totalMaxMemory > TOTAL_HARD_MEMORY_LIMIT) {
+ if (totalMaxMemory > hardMemoryLimit) {
LOG(info, "flush.memory.maxmemory=%ld cannot"
- " be set above the hard limit of %ld (16GB) so we cap it to the hard limit",
+ " be set above the hard limit of %ld so we cap it to the hard limit",
config.maxmemory,
- TOTAL_HARD_MEMORY_LIMIT);
- totalMaxMemory = TOTAL_HARD_MEMORY_LIMIT;
+ hardMemoryLimit);
+ totalMaxMemory = hardMemoryLimit;
}
size_t eachMaxMemory = config.each.maxmemory;
- if (eachMaxMemory > EACH_HARD_MEMORY_LIMIT) {
+ if (eachMaxMemory > hardMemoryLimit) {
LOG(info, "flush.memory.each.maxmemory=%ld cannot"
- " be set above the hard limit of %ld (12GB) so we cap it to the hard limit",
+ " be set above the hard limit of %ld so we cap it to the hard limit",
config.maxmemory,
- EACH_HARD_MEMORY_LIMIT);
- eachMaxMemory = EACH_HARD_MEMORY_LIMIT;
+ hardMemoryLimit);
+ eachMaxMemory = hardMemoryLimit;
}
return MemoryFlush::Config(totalMaxMemory,
config.maxtlssize,
diff --git a/searchcore/src/vespa/searchcore/proton/server/memory_flush_config_updater.h b/searchcore/src/vespa/searchcore/proton/server/memory_flush_config_updater.h
index 5ccced99920..e6d8f7610f8 100644
--- a/searchcore/src/vespa/searchcore/proton/server/memory_flush_config_updater.h
+++ b/searchcore/src/vespa/searchcore/proton/server/memory_flush_config_updater.h
@@ -5,6 +5,7 @@
#include "i_disk_mem_usage_listener.h"
#include "memoryflush.h"
#include <vespa/searchcore/config/config-proton.h>
+#include <vespa/searchcore/proton/common/hw_info.h>
#include <mutex>
namespace proton {
@@ -23,6 +24,7 @@ private:
Mutex _mutex;
MemoryFlush::SP _flushStrategy;
ProtonConfig::Flush::Memory _currConfig;
+ HwInfo::Memory _memory;
DiskMemUsageState _currState;
bool _useConservativeDiskMode;
bool _useConservativeMemoryMode;
@@ -38,11 +40,13 @@ public:
using UP = std::unique_ptr<MemoryFlushConfigUpdater>;
MemoryFlushConfigUpdater(const MemoryFlush::SP &flushStrategy,
- const ProtonConfig::Flush::Memory &config);
+ const ProtonConfig::Flush::Memory &config,
+ const HwInfo::Memory &memory);
void setConfig(const ProtonConfig::Flush::Memory &newConfig);
virtual void notifyDiskMemUsage(DiskMemUsageState newState) override;
- static MemoryFlush::Config convertConfig(const ProtonConfig::Flush::Memory &config);
+ static MemoryFlush::Config convertConfig(const ProtonConfig::Flush::Memory &config,
+ const HwInfo::Memory &memory);
};
} // namespace proton
diff --git a/searchcore/src/vespa/searchcore/proton/server/proton.cpp b/searchcore/src/vespa/searchcore/proton/server/proton.cpp
index eefef25911f..09890ae41ef 100644
--- a/searchcore/src/vespa/searchcore/proton/server/proton.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/proton.cpp
@@ -266,8 +266,8 @@ Proton::init(const BootstrapConfig::SP & configSnapshot)
switch (flush.strategy) {
case ProtonConfig::Flush::MEMORY: {
auto memoryFlush = std::make_shared<MemoryFlush>(
- MemoryFlushConfigUpdater::convertConfig(flush.memory), fastos::ClockSystem::now());
- _memoryFlushConfigUpdater = std::make_unique<MemoryFlushConfigUpdater>(memoryFlush, flush.memory);
+ MemoryFlushConfigUpdater::convertConfig(flush.memory, _hwInfo.memory()), fastos::ClockSystem::now());
+ _memoryFlushConfigUpdater = std::make_unique<MemoryFlushConfigUpdater>(memoryFlush, flush.memory, _hwInfo.memory());
_diskMemUsageSampler->notifier().addDiskMemUsageListener(_memoryFlushConfigUpdater.get());
strategy = memoryFlush;
break;