Skip to content

Commit c6fa4a8

Browse files
mkaruzaBagritsevichStepan
authored andcommitted
Threshold RSS memory limit upper bound is max_memory
1 parent bf32c8b commit c6fa4a8

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/server/engine_shard.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -721,8 +721,11 @@ size_t EngineShard::CalculateEvictionBytes() {
721721
<< "Used memory goal bytes: " << goal_bytes << ", used memory: " << global_used_memory
722722
<< ", memory limit: " << max_memory_limit;
723723

724-
// If rss_oom_deny_ratio is set, we should evict depending on rss memory too
725-
const double rss_oom_deny_ratio = ServerState::tlocal()->rss_oom_deny_ratio;
724+
// RSS memory limit is always max_memory_limit or if rss_oom_deny_ratio is used than we should
725+
// respect but upper limit is again max_memory.
726+
const double rss_oom_deny_ratio = ServerState::tlocal()->rss_oom_deny_ratio > 0.
727+
? std::min(ServerState::tlocal()->rss_oom_deny_ratio, 1.)
728+
: 1.;
726729
// Check for `enable_heartbeat_rss_eviction` flag since it dynamic. And reset state
727730
// if flag has changed.
728731
bool rss_eviction_enabled_flag = GetFlag(FLAGS_enable_heartbeat_rss_eviction);
@@ -731,7 +734,7 @@ size_t EngineShard::CalculateEvictionBytes() {
731734
eviction_state_.deleted_bytes_before_rss_update = 0;
732735
eviction_state_.rss_eviction_enabled_ = rss_eviction_enabled_flag;
733736
}
734-
if (rss_oom_deny_ratio > 0.0 && eviction_state_.rss_eviction_enabled_) {
737+
if (eviction_state_.rss_eviction_enabled_) {
735738
const size_t max_rss_memory = size_t(rss_oom_deny_ratio * max_memory_limit);
736739
/* We start eviction when we have less than eviction_memory_budget_threshold * 100% of free rss
737740
* memory */

tests/dragonfly/memory_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ async def test_eviction_on_rss_treshold(df_factory: DflyInstanceFactory, heartbe
200200
df_server.start()
201201
client = df_server.client()
202202

203-
data_fill_size = int(0.80 * max_memory) # 85% of max_memory
203+
data_fill_size = int(0.70 * max_memory) # 70% of max_memory
204204

205205
val_size = 1024 * 5 # 5 kb
206206
num_keys = data_fill_size // val_size

0 commit comments

Comments
 (0)