aboutsummaryrefslogtreecommitdiffstats
path: root/searchcommon
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@online.no>2021-04-09 13:28:14 +0200
committerTor Egge <Tor.Egge@online.no>2021-04-09 13:34:07 +0200
commit4977b304ca6e5468af47b91bd8526e1615a34fe1 (patch)
treee44fbfa3e61f518128cc88f1d51b36c5a5e88cd3 /searchcommon
parentcef30b122011ac98ef5b398eed50df942d95d9c6 (diff)
Add CompactionStrategy methods to determine if compaction should be performed.
Diffstat (limited to 'searchcommon')
-rw-r--r--searchcommon/src/vespa/searchcommon/common/compaction_strategy.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/searchcommon/src/vespa/searchcommon/common/compaction_strategy.h b/searchcommon/src/vespa/searchcommon/common/compaction_strategy.h
index 8a9b94f3af8..65a7b5a276c 100644
--- a/searchcommon/src/vespa/searchcommon/common/compaction_strategy.h
+++ b/searchcommon/src/vespa/searchcommon/common/compaction_strategy.h
@@ -32,6 +32,20 @@ public:
_maxDeadAddressSpaceRatio == rhs._maxDeadAddressSpaceRatio;
}
bool operator!=(const CompactionStrategy & rhs) const { return !(operator==(rhs)); }
+
+ static constexpr size_t DEAD_BYTES_SLACK = 0x10000u;
+
+ bool should_compact_memory(size_t used_bytes, size_t dead_bytes) const {
+ return ((dead_bytes >= DEAD_BYTES_SLACK) &&
+ (dead_bytes > used_bytes * getMaxDeadBytesRatio()));
+ }
+
+ static constexpr size_t DEAD_ADDRESS_SPACE_SLACK = 0x10000u;
+
+ bool should_compact_address_space(size_t used_address_space, size_t dead_address_space) const {
+ return ((dead_address_space >= DEAD_ADDRESS_SPACE_SLACK) &&
+ (dead_address_space > used_address_space * getMaxDeadAddressSpaceRatio()));
+ }
};
std::ostream& operator<<(std::ostream& os, const CompactionStrategy& compaction_strategy);