[pmg-devel] [PATCH pmg-api v3] config: adjust max_filters calculation to reflect current memory usage

Markus Frank m.frank at proxmox.com
Thu Jan 18 15:55:32 CET 2024


Change max_filters calculation for systems with recommended memory
setup (>4GB).

The values of 2816 and 150 are based on testing with 4GB, 6GB & 8GB
memory configurations, large and small numbers of added objects and
sending multiple mails simultaneously.

On setups with less memory, it is difficult to completely prevent OOM kills.
So for these setups the calculation remains similar, but a warning is sent.

Related OOM killer problem found in forum:
https://forum.proxmox.com/threads/123531/

Signed-off-by: Markus Frank <m.frank at proxmox.com>
---
Tested edge cases with setting min_servers to max_servers
in src/bin/pmg-smtp-filter

 src/PMG/Config.pm | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/PMG/Config.pm b/src/PMG/Config.pm
index 7339e0d..061396e 100644
--- a/src/PMG/Config.pm
+++ b/src/PMG/Config.pm
@@ -459,8 +459,17 @@ sub get_max_filters {
 
     my $max_servers = 5;
     my $servermem = 120;
+    my $base;
     my $memory = physical_memory();
-    my $add_servers = int(($memory - 512)/$servermem);
+    if ($memory < 3840) {
+	warn "low amount of system memory installed, recommended is 4+ GB\n"
+	    ."to prevent OOM kills, it is better to set max_filters manually\n";
+	$base = $memory > 1536 ? 1024 : 512;
+    } else {
+	$base = 2816;
+	$servermem = 150;
+    }
+    my $add_servers = int(($memory - $base)/$servermem);
     $max_servers += $add_servers if $add_servers > 0;
     $max_servers = 40 if  $max_servers > 40;
 
-- 
2.39.2





More information about the pmg-devel mailing list