aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2019-12-20 07:10:13 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2019-12-20 07:10:13 +0000
commite680dcc01f69c0be5263528433ed6c9752e3f3f2 (patch)
treeef448f04d21292f8ba0b5ebfa48410ebd3ee0c65 /searchcore
parent924c24a52fb8bfbb61d890e03183d0c2f667bd7b (diff)
Add test for 1% capping.
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/tests/proton/matching/matching_stats_test.cpp10
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/matching_stats.cpp2
2 files changed, 11 insertions, 1 deletions
diff --git a/searchcore/src/tests/proton/matching/matching_stats_test.cpp b/searchcore/src/tests/proton/matching/matching_stats_test.cpp
index 0d7778274b8..48ab09ffcb2 100644
--- a/searchcore/src/tests/proton/matching/matching_stats_test.cpp
+++ b/searchcore/src/tests/proton/matching/matching_stats_test.cpp
@@ -320,6 +320,16 @@ TEST("requireThatSoftDoomFacorIsComputedCorrectlyForUpAdjustment") {
EXPECT_EQUAL(0.105, stats.softDoomFactor());
}
+TEST("requireThatFactor is capped at minimum 1%") {
+ MatchingStats stats;
+ stats.softDoomFactor(0.01001);
+ EXPECT_EQUAL(0.01001, stats.softDoomFactor());
+ stats.updatesoftDoomFactor(1s, 500ms, 900ms);
+ EXPECT_EQUAL(0.01, stats.softDoomFactor());
+ stats.updatesoftDoomFactor(1s, 900ms, 1ms);
+ EXPECT_EQUAL(0.0105, stats.softDoomFactor());
+}
+
TEST_MAIN() {
TEST_RUN_ALL();
}
diff --git a/searchcore/src/vespa/searchcore/proton/matching/matching_stats.cpp b/searchcore/src/vespa/searchcore/proton/matching/matching_stats.cpp
index 3526b7f206f..fff8c94c8be 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/matching_stats.cpp
+++ b/searchcore/src/vespa/searchcore/proton/matching/matching_stats.cpp
@@ -90,7 +90,7 @@ MatchingStats::updatesoftDoomFactor(vespalib::duration hardLimit, vespalib::dura
double diff = vespalib::to_s(softLimit - duration)/vespalib::to_s(hardLimit);
if (duration < softLimit) {
// Since softdoom factor can become very small, allow a minimum change of some size
- diff = std::min(diff, std::max(0.1, _softDoomFactor)*MAX_CHANGE_FACTOR);
+ diff = std::min(diff, _softDoomFactor*MAX_CHANGE_FACTOR);
_softDoomFactor += 0.01*diff;
} else {
diff = std::max(diff, -_softDoomFactor*MAX_CHANGE_FACTOR);