mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 18:35:46 +02:00
feat(server): introduce table_growth_margin flag (#2678)
* feat(server): introduce table_growth_margin flag Signed-off-by: adi_holden <adi@dragonflydb.io>
This commit is contained in:
parent
93debc754c
commit
7c443f3a15
2 changed files with 8 additions and 2 deletions
|
@ -27,6 +27,10 @@ ABSL_FLAG(uint32_t, max_segment_to_consider, 4,
|
|||
"The maximum number of dashtable segments to scan in each eviction "
|
||||
"when heartbeat based eviction is triggered under memory pressure.");
|
||||
|
||||
ABSL_FLAG(double, table_growth_margin, 1.1,
|
||||
"Prevents table from growing if number of free slots x average object size x this ratio "
|
||||
"is larger than memory budget.");
|
||||
|
||||
namespace dfly {
|
||||
|
||||
using namespace std;
|
||||
|
@ -137,8 +141,9 @@ bool PrimeEvictionPolicy::CanGrow(const PrimeTable& tbl) const {
|
|||
// even though we may currently use less memory.
|
||||
// see https://github.com/dragonflydb/dragonfly/issues/256#issuecomment-1227095503
|
||||
size_t new_available = (tbl.capacity() - tbl.size()) + PrimeTable::kSegCapacity;
|
||||
bool res = mem_budget_ >
|
||||
int64_t(PrimeTable::kSegBytes + db_slice_->bytes_per_object() * new_available * 1.1);
|
||||
bool res =
|
||||
mem_budget_ > int64_t(PrimeTable::kSegBytes + db_slice_->bytes_per_object() * new_available *
|
||||
GetFlag(FLAGS_table_growth_margin));
|
||||
VLOG(2) << "available: " << new_available << ", res: " << res;
|
||||
|
||||
return res;
|
||||
|
|
|
@ -804,6 +804,7 @@ void Service::Init(util::AcceptServer* acceptor, std::vector<facade::Listener*>
|
|||
config_registry.RegisterMutable("max_segment_to_consider");
|
||||
config_registry.RegisterMutable("enable_heartbeat_eviction");
|
||||
config_registry.RegisterMutable("dbfilename");
|
||||
config_registry.RegisterMutable("table_growth_margin");
|
||||
|
||||
uint32_t shard_num = GetFlag(FLAGS_num_shards);
|
||||
if (shard_num == 0 || shard_num > pp_.size()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue