feat(server): introduce rss oom limit (#3702)

* introduce rss denyoom limit

Signed-off-by: adi_holden <adi@dragonflydb.io>
This commit is contained in:
adiholden 2024-09-22 13:28:24 +03:00 committed by GitHub
parent 5cf917871c
commit 4d38271efa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 209 additions and 64 deletions

View file

@ -113,13 +113,14 @@ void ServerState::Destroy() {
state_ = nullptr;
}
uint64_t ServerState::GetUsedMemory(uint64_t now_ns) {
ServerState::MemoryUsageStats ServerState::GetMemoryUsage(uint64_t now_ns) {
static constexpr uint64_t kCacheEveryNs = 1000;
if (now_ns > used_mem_last_update_ + kCacheEveryNs) {
used_mem_last_update_ = now_ns;
used_mem_cached_ = used_mem_current.load(std::memory_order_relaxed);
memory_stats_cached_.used_mem = used_mem_current.load(std::memory_order_relaxed);
memory_stats_cached_.rss_mem = rss_mem_current.load(std::memory_order_relaxed);
}
return used_mem_cached_;
return memory_stats_cached_;
}
bool ServerState::AllowInlineScheduling() const {