feat(tiering): simple offload loop (#2987)

Simple offloading for tiering

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
This commit is contained in:
Vladislav 2024-05-06 22:28:45 +03:00 committed by GitHub
parent 8697b20a9e
commit f27506e678
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 144 additions and 19 deletions

View file

@ -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.