From 8e783ebd8f1eac5c6c5cf9f82e5f07ab519ab460 Mon Sep 17 00:00:00 2001 From: Rongxin Xia Date: Tue, 14 Jan 2025 15:48:46 -0800 Subject: [PATCH] allow ARL to switch to check for all memory for load shedding based on config Summary: This is to support ARL to switch to check for all memory based on the new enum - a new enum `CGroupResourceMemoryType` is introduced, `CgroupResources` can be initialized based `CGroupResourceMemoryType` to check `anon` or `all` memory - I don't use a flag in config as this flag will not be included in `arlConfig` and every service initialize the resource differently, so I just let the service determine whether they want to initialize with different memory type. - delete all APIs / counters related to `memAll` as after this diff we will only have one view of mem (more discussion [here](https://fb.workplace.com/groups/proxygendevelopers/posts/3064051317235572/?comment_id=3064123973894973&fbclid=IwZXh0bgNhZW0CMTEAAR0i2R_cHSSEKChgn7vq_1u9aCDnCIY4xzaeHkUyFLqxR4TfbZh55f8kbPI_aem_k0DpcV2UpwH-h4LErupCkA)) See more discussion in https://fb.workplace.com/groups/proxygendevelopers/permalink/3441253179515382/ (S479847). TLDR edgetee OOM because of socket mem but ARL doesn't count it so ARL didn't kick in. Reviewed By: dddmello Differential Revision: D67954452 fbshipit-source-id: 3b99555ed644ac57e80da44d7a01c8ae1568a9a9 --- proxygen/lib/stats/ResourceData.h | 25 +------------------------ proxygen/lib/stats/test/MockResources.h | 1 - 2 files changed, 1 insertion(+), 25 deletions(-) diff --git a/proxygen/lib/stats/ResourceData.h b/proxygen/lib/stats/ResourceData.h index 5c0bea20f0..166159997a 100644 --- a/proxygen/lib/stats/ResourceData.h +++ b/proxygen/lib/stats/ResourceData.h @@ -132,14 +132,6 @@ struct ResourceData : public PeriodicStatsDataBase { return usedMemBytes_; } - // Similar to getUsedMemBytes but difference is that - // `getUsedMemBytes` only contains anon memory while - // `getUsedMemBytesAll` contains file cache and all the other - // types of memory - uint64_t getUsedMemBytesAll() const { - return usedMemBytesAll_; - } - [[nodiscard]] double getMemPressureAvg10Pct() const { return memPressureAvg10Pct_; } @@ -194,15 +186,6 @@ struct ResourceData : public PeriodicStatsDataBase { return ((double)usedMemBytes_) / totalMemBytes_ * 100; } - double getUsedMemAllPct() const { - return ((double)usedMemBytesAll_) / totalMemBytes_ * 100; - } - - // Gets the used total memory (0-1.0) of the system as a ratio - double getUsedMemAllRatio() const { - return ((double)usedMemBytesAll_) / totalMemBytes_; - } - // Gets the used anonymous memory (0-1.0) of the system as a ratio double getUsedMemRatio() const { return ((double)usedMemBytes_) / totalMemBytes_; @@ -342,11 +325,8 @@ struct ResourceData : public PeriodicStatsDataBase { softIrqCpuCoreRatioUtils_ = std::move(softIrqCpuCoreRatioUtils); } - void setMemStats(uint64_t usedMemBytes, - uint64_t usedMemBytesAll, - uint64_t totalMemBytes) { + void setMemStats(uint64_t usedMemBytes, uint64_t totalMemBytes) { usedMemBytes_ = usedMemBytes; - usedMemBytesAll_ = usedMemBytesAll; totalMemBytes_ = totalMemBytes; } @@ -411,9 +391,6 @@ struct ResourceData : public PeriodicStatsDataBase { double cpuSoftIrqRatioUtil_{0}; std::vector softIrqCpuCoreRatioUtils_; uint64_t usedMemBytes_{0}; - // usedMemBytes_ contains only anon memory while usedMemBytesAll_ contains - // all the memory including file cache. - uint64_t usedMemBytesAll_{0}; uint64_t totalMemBytes_{0}; uint64_t tcpMemoryPages_{0}; uint64_t maxTcpMemLimit_{0}; diff --git a/proxygen/lib/stats/test/MockResources.h b/proxygen/lib/stats/test/MockResources.h index 5090426257..e9fa5f7d2b 100644 --- a/proxygen/lib/stats/test/MockResources.h +++ b/proxygen/lib/stats/test/MockResources.h @@ -60,7 +60,6 @@ class MockResources : public proxygen::Resources { std::vector(params.numCpuCores, params.cpuSoftIrqUtilRatio)); uint64_t totalMemBytes = 100; data.setMemStats( - folly::to(round(params.memUtilRatio * totalMemBytes)), folly::to(round(params.memUtilRatio * totalMemBytes)), totalMemBytes); uint64_t totalNetMemBytes = 100;