diff options
author | Geir Storli <geirst@yahoo-inc.com> | 2016-06-30 14:53:04 +0200 |
---|---|---|
committer | Geir Storli <geirst@yahoo-inc.com> | 2016-06-30 14:53:04 +0200 |
commit | 72279659546cebd2ef28c02b2911f431f85f8a39 (patch) | |
tree | 60133121124d0d4fc07f2971068968f72288c227 /searchcore/src/tests/proton/server/memory_flush_config_updater | |
parent | 25e2a3081c5beb523fec71d2545e934a335c0c40 (diff) |
Change settings for conservative mode in memory flush strategy from absolute to relative.
Also choose conservative value for memory usage by a single flush component (each.maxmemory).
Diffstat (limited to 'searchcore/src/tests/proton/server/memory_flush_config_updater')
-rw-r--r-- | searchcore/src/tests/proton/server/memory_flush_config_updater/memory_flush_config_updater_test.cpp | 55 |
1 files changed, 29 insertions, 26 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 9adb385d2e5..21d8e70c472 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 @@ -8,15 +8,17 @@ using namespace proton; using vespa::config::search::core::ProtonConfig; ProtonConfig::Flush::Memory -getConfig(int64_t maxMemory, int64_t conservativeMaxMemory, - int64_t maxTlsSize, int64_t conservativeMaxTlsSize, +getConfig(int64_t maxMemory, int64_t eachMaxMemory, int64_t maxTlsSize, + double conservativeMemoryLimitFactor = 0.5, + double conservativeDiskLimitFactor = 0.6, double lowWatermarkFactor = 0.8) { ProtonConfig::Flush::Memory result; result.maxmemory = maxMemory; + result.each.maxmemory = eachMaxMemory; result.maxtlssize = maxTlsSize; - result.conservative.maxmemory = conservativeMaxMemory; - result.conservative.maxtlssize = conservativeMaxTlsSize; + result.conservative.memorylimitfactor = conservativeMemoryLimitFactor; + result.conservative.disklimitfactor = conservativeDiskLimitFactor; result.conservative.lowwatermarkfactor = lowWatermarkFactor; return result; } @@ -24,7 +26,7 @@ getConfig(int64_t maxMemory, int64_t conservativeMaxMemory, ProtonConfig::Flush::Memory getDefaultConfig() { - return getConfig(4, 2, 20, 10); + return getConfig(4, 1, 20); } ResourceUsageState @@ -48,8 +50,9 @@ struct Fixture : strategy(std::make_shared<MemoryFlush>(MemoryFlushConfigUpdater::convertConfig(getDefaultConfig()))), updater(strategy, getDefaultConfig()) {} - void assertStrategyConfig(int64_t expMaxGlobalMemory, int64_t expMaxGlobalTlsSize) { + void assertStrategyConfig(int64_t expMaxGlobalMemory, int64_t expMaxEachMemory, int64_t expMaxGlobalTlsSize) { EXPECT_EQUAL(expMaxGlobalMemory, strategy->getConfig().maxGlobalMemory); + EXPECT_EQUAL(expMaxEachMemory, strategy->getConfig().maxMemoryGain); EXPECT_EQUAL(expMaxGlobalTlsSize, strategy->getConfig().maxGlobalTlsSize); } void notifyDiskMemUsage(const ResourceUsageState &diskState, const ResourceUsageState &memoryState) { @@ -59,74 +62,74 @@ struct Fixture TEST_F("require that strategy is updated when setting new config", Fixture) { - f.updater.setConfig(getConfig(5, 3, 30, 15)); - TEST_DO(f.assertStrategyConfig(5, 30)); + f.updater.setConfig(getConfig(6, 3, 30)); + TEST_DO(f.assertStrategyConfig(6, 3, 30)); } TEST_F("require that strategy is updated with normal values if no limits are reached", Fixture) { f.updater.notifyDiskMemUsage(DiskMemUsageState()); - TEST_DO(f.assertStrategyConfig(4, 20)); + TEST_DO(f.assertStrategyConfig(4, 1, 20)); } TEST_F("require that strategy is updated with conservative max tls size value if disk limit is reached", Fixture) { f.notifyDiskMemUsage(aboveLimit(), belowLimit()); - TEST_DO(f.assertStrategyConfig(4, 10)); + TEST_DO(f.assertStrategyConfig(4, 1, 12)); } TEST_F("require that strategy is updated with conservative max memory value if memory limit is reached", Fixture) { f.notifyDiskMemUsage(belowLimit(), aboveLimit()); - TEST_DO(f.assertStrategyConfig(2, 20)); + TEST_DO(f.assertStrategyConfig(2, 0.5, 20)); } TEST_F("require that strategy is updated with all conservative values if both limits are reached", Fixture) { f.notifyDiskMemUsage(aboveLimit(), aboveLimit()); - TEST_DO(f.assertStrategyConfig(2, 10)); + TEST_DO(f.assertStrategyConfig(2, 0.5, 12)); } TEST_F("require that last disk/memory usage state is remembered when setting new config", Fixture) { f.notifyDiskMemUsage(aboveLimit(), belowLimit()); - f.updater.setConfig(getConfig(5, 3, 30, 15)); - TEST_DO(f.assertStrategyConfig(5, 15)); + f.updater.setConfig(getConfig(6, 3, 30)); + TEST_DO(f.assertStrategyConfig(6, 3, 18)); } TEST_F("require that last config if remembered when setting new disk/memory usage state", Fixture) { - f.updater.setConfig(getConfig(5, 3, 30, 15)); + f.updater.setConfig(getConfig(6, 3, 30)); f.notifyDiskMemUsage(aboveLimit(), belowLimit()); - TEST_DO(f.assertStrategyConfig(5, 15)); + TEST_DO(f.assertStrategyConfig(6, 3, 18)); } TEST_F("require that we must go below low watermark for disk usage before using normal tls size value again", Fixture) { f.notifyDiskMemUsage(ResourceUsageState(0.7, 0.8), belowLimit()); - TEST_DO(f.assertStrategyConfig(4, 10)); + TEST_DO(f.assertStrategyConfig(4, 1, 12)); f.notifyDiskMemUsage(ResourceUsageState(0.7, 0.7), belowLimit()); - TEST_DO(f.assertStrategyConfig(4, 10)); + TEST_DO(f.assertStrategyConfig(4, 1, 12)); f.notifyDiskMemUsage(ResourceUsageState(0.7, 0.56), belowLimit()); - TEST_DO(f.assertStrategyConfig(4, 10)); + TEST_DO(f.assertStrategyConfig(4, 1, 12)); f.notifyDiskMemUsage(ResourceUsageState(0.7, 0.55), belowLimit()); - TEST_DO(f.assertStrategyConfig(4, 20)); + TEST_DO(f.assertStrategyConfig(4, 1, 20)); f.notifyDiskMemUsage(ResourceUsageState(0.7, 0.6), belowLimit()); - TEST_DO(f.assertStrategyConfig(4, 20)); + TEST_DO(f.assertStrategyConfig(4, 1, 20)); } TEST_F("require that we must go below low watermark for memory usage before using normal max memory value again", Fixture) { f.notifyDiskMemUsage(belowLimit(), ResourceUsageState(0.7, 0.8)); - TEST_DO(f.assertStrategyConfig(2, 20)); + TEST_DO(f.assertStrategyConfig(2, 0.5, 20)); f.notifyDiskMemUsage(belowLimit(), ResourceUsageState(0.7, 0.7)); - TEST_DO(f.assertStrategyConfig(2, 20)); + TEST_DO(f.assertStrategyConfig(2, 0.5, 20)); f.notifyDiskMemUsage(belowLimit(), ResourceUsageState(0.7, 0.56)); - TEST_DO(f.assertStrategyConfig(2, 20)); + TEST_DO(f.assertStrategyConfig(2, 0.5, 20)); f.notifyDiskMemUsage(belowLimit(), ResourceUsageState(0.7, 0.55)); - TEST_DO(f.assertStrategyConfig(4, 20)); + TEST_DO(f.assertStrategyConfig(4, 1, 20)); f.notifyDiskMemUsage(belowLimit(), ResourceUsageState(0.7, 0.6)); - TEST_DO(f.assertStrategyConfig(4, 20)); + TEST_DO(f.assertStrategyConfig(4, 1, 20)); } TEST_MAIN() { TEST_RUN_ALL(); } |