diff options
author | Tor Egge <Tor.Egge@online.no> | 2021-12-10 12:29:34 +0100 |
---|---|---|
committer | Tor Egge <Tor.Egge@online.no> | 2021-12-10 12:29:34 +0100 |
commit | 7ee2c049d2adc8b4b0af81149399586d7d29eafe (patch) | |
tree | eb97a40c74bc6fa7f773c5a84b3c1aec836b9374 /vespalib/src | |
parent | 175cc78a3934916aa21680c88c3aa09de127a7bd (diff) |
Add max buffers to CompactionStrategy.
Diffstat (limited to 'vespalib/src')
-rw-r--r-- | vespalib/src/vespa/vespalib/datastore/compaction_strategy.h | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/vespalib/src/vespa/vespalib/datastore/compaction_strategy.h b/vespalib/src/vespa/vespalib/datastore/compaction_strategy.h index df7ca1657cb..9ca4a64a55b 100644 --- a/vespalib/src/vespa/vespalib/datastore/compaction_strategy.h +++ b/vespalib/src/vespa/vespalib/datastore/compaction_strategy.h @@ -3,6 +3,7 @@ #pragma once #include <iosfwd> +#include <cstdint> namespace vespalib { @@ -26,6 +27,7 @@ public: private: double _maxDeadBytesRatio; // Max ratio of dead bytes before compaction double _maxDeadAddressSpaceRatio; // Max ratio of dead address space before compaction + uint32_t _max_buffers; // Max number of buffers to compact for each reason (memory usage, address space usage) bool should_compact_memory(size_t used_bytes, size_t dead_bytes) const { return ((dead_bytes >= DEAD_BYTES_SLACK) && (dead_bytes > used_bytes * getMaxDeadBytesRatio())); @@ -37,19 +39,29 @@ private: public: CompactionStrategy() noexcept : _maxDeadBytesRatio(0.05), - _maxDeadAddressSpaceRatio(0.2) + _maxDeadAddressSpaceRatio(0.2), + _max_buffers(1) { } CompactionStrategy(double maxDeadBytesRatio, double maxDeadAddressSpaceRatio) noexcept : _maxDeadBytesRatio(maxDeadBytesRatio), - _maxDeadAddressSpaceRatio(maxDeadAddressSpaceRatio) + _maxDeadAddressSpaceRatio(maxDeadAddressSpaceRatio), + _max_buffers(1) + { + } + CompactionStrategy(double maxDeadBytesRatio, double maxDeadAddressSpaceRatio, uint32_t max_buffers) noexcept + : _maxDeadBytesRatio(maxDeadBytesRatio), + _maxDeadAddressSpaceRatio(maxDeadAddressSpaceRatio), + _max_buffers(max_buffers) { } double getMaxDeadBytesRatio() const { return _maxDeadBytesRatio; } double getMaxDeadAddressSpaceRatio() const { return _maxDeadAddressSpaceRatio; } + uint32_t get_max_buffers() const noexcept { return _max_buffers; } bool operator==(const CompactionStrategy & rhs) const { - return _maxDeadBytesRatio == rhs._maxDeadBytesRatio && - _maxDeadAddressSpaceRatio == rhs._maxDeadAddressSpaceRatio; + return (_maxDeadBytesRatio == rhs._maxDeadBytesRatio) && + (_maxDeadAddressSpaceRatio == rhs._maxDeadAddressSpaceRatio) && + (_max_buffers == rhs._max_buffers); } bool operator!=(const CompactionStrategy & rhs) const { return !(operator==(rhs)); } |