mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 10:25:47 +02:00
feat(tiering): simple offload loop (#2987)
Simple offloading for tiering Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
This commit is contained in:
parent
8697b20a9e
commit
f27506e678
12 changed files with 144 additions and 19 deletions
|
@ -51,7 +51,7 @@ ABSL_FLAG(uint32_t, hz, 100,
|
|||
ABSL_FLAG(bool, cache_mode, false,
|
||||
"If true, the backend behaves like a cache, "
|
||||
"by evicting entries when getting close to maxmemory limit");
|
||||
// memory defragmented related flags
|
||||
|
||||
ABSL_FLAG(float, mem_defrag_threshold, 0.7,
|
||||
"Minimum percentage of used memory relative to maxmemory cap before running "
|
||||
"defragmentation");
|
||||
|
@ -582,6 +582,8 @@ void EngineShard::Heartbeat() {
|
|||
}
|
||||
|
||||
ssize_t eviction_redline = (max_memory_limit * kRedLimitFactor) / shard_set->size();
|
||||
size_t tiering_redline =
|
||||
(max_memory_limit * GetFlag(FLAGS_tiered_offload_threshold)) / shard_set->size();
|
||||
|
||||
DbContext db_cntx;
|
||||
db_cntx.time_now_ms = GetCurrentTimeMs();
|
||||
|
@ -603,6 +605,10 @@ void EngineShard::Heartbeat() {
|
|||
if (db_slice_.memory_budget() < eviction_redline) {
|
||||
db_slice_.FreeMemWithEvictionStep(i, eviction_redline - db_slice_.memory_budget());
|
||||
}
|
||||
|
||||
if (tiered_storage_ && UsedMemory() > tiering_redline) {
|
||||
tiered_storage_->RunOffloading(i);
|
||||
}
|
||||
}
|
||||
|
||||
// Journal entries for expired entries are not writen to socket in the loop above.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue