From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <pve-devel-bounces@lists.proxmox.com> Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id E9EA71FF189 for <inbox@lore.proxmox.com>; Fri, 4 Apr 2025 14:47:15 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D000F1EE2D; Fri, 4 Apr 2025 14:46:59 +0200 (CEST) From: Christoph Heiss <c.heiss@proxmox.com> To: pve-devel@lists.proxmox.com Date: Fri, 4 Apr 2025 14:46:46 +0200 Message-ID: <20250404124651.1283950-2-c.heiss@proxmox.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250404124651.1283950-1-c.heiss@proxmox.com> References: <20250404124651.1283950-1-c.heiss@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.030 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [zfs-arc-max.pl, runenv.pm, proxmox.com] Subject: [pve-devel] [PATCH installer 1/3] run env: always return proper value for default zfs max arc size X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com> List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe> List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/> List-Post: <mailto:pve-devel@lists.proxmox.com> List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help> List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe> Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com> In preparation for fixing #6285 [0]. `0` means to just skip writing the module parameter. But (especially) with the upcoming change in ZFS 2.3 - which makes the size basically that of the system memory minus 1 GiB - we want to always write some value. [0] https://bugzilla.proxmox.com/show_bug.cgi?id=6285 Signed-off-by: Christoph Heiss <c.heiss@proxmox.com> --- Proxmox/Install/RunEnv.pm | 9 +++++---- test/zfs-arc-max.pl | 42 +++++++++++++++++++++++++-------------- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/Proxmox/Install/RunEnv.pm b/Proxmox/Install/RunEnv.pm index 407d05c..02c603d 100644 --- a/Proxmox/Install/RunEnv.pm +++ b/Proxmox/Install/RunEnv.pm @@ -337,14 +337,15 @@ sub default_zfs_arc_max { my $product = Proxmox::Install::ISOEnv::get('product'); my $total_memory = query_total_memory(); - # By default limit PVE and low-memory systems, for all others let ZFS decide on its own by - # returning `0`, which causes the installer to skip writing the `zfs_arc_max` module parameter. + # By default limit PVE and low-memory systems, for all just use the 50% of system memory if ($product ne 'pve') { - return 0 if $total_memory >= 2048 && $product ne 'pmg'; - return 0 if $total_memory >= 4096; # PMG's base memory requirement is much higer + my $zfs_default_mib = int(sprintf('%.0f', $total_memory / 2)); + return $zfs_default_mib if $total_memory >= 2048 && $product ne 'pmg'; + return $zfs_default_mib if $total_memory >= 4096; # PMG's base memory requirement is much higher } my $default_mib = $total_memory * $ZFS_ARC_SYSMEM_PERCENTAGE; + # int(sprintf()) rounds up instead of truncating my $rounded_mib = int(sprintf('%.0f', $default_mib)); if ($rounded_mib > $ZFS_ARC_MAX_SIZE_MIB) { diff --git a/test/zfs-arc-max.pl b/test/zfs-arc-max.pl index 8cf093f..a8c0a37 100755 --- a/test/zfs-arc-max.pl +++ b/test/zfs-arc-max.pl @@ -21,8 +21,10 @@ sub mock_product { ); } -my %default_tests = ( - 16 => 64, # at least 64 MiB +use constant ZFS_ARC_MIN_MIB => 64; + +my %default_tests_pve = ( + 16 => ZFS_ARC_MIN_MIB, # at least 64 MiB 1024 => 102, 4 * 1024 => 410, 8 * 1024 => 819, @@ -31,26 +33,36 @@ my %default_tests = ( 1024 * 1024 => 16384, # maximum of 16 GiB ); -while (my ($total_mem, $expected) = each %default_tests) { +my %default_tests_others = ( + 16 => ZFS_ARC_MIN_MIB, # at least 64 MiB + 1024 => 102, + 4 * 1024 => 2048, + 8 * 1024 => 4096, + 150 * 1024 => 76800, + 160 * 1024 => 81920, + 1024 * 1024 => 524288, +); + +mock_product('pve'); +while (my ($total_mem, $expected) = each %default_tests_pve) { $proxmox_install_runenv->redefine( query_total_memory => sub { return $total_mem; }, ); - mock_product('pve'); is(Proxmox::Install::RunEnv::default_zfs_arc_max(), $expected, - "$expected MiB should be zfs_arc_max for PVE with $total_mem MiB system memory"); + "zfs_arc_max should default to $expected for pve with $total_mem MiB system memory"); +} - mock_product('pbs'); - is(Proxmox::Install::RunEnv::default_zfs_arc_max(), $total_mem < 2048 ? $expected : 0, - "zfs_arc_max should default to `0` for PBS with $total_mem MiB system memory"); +while (my ($total_mem, $expected) = each %default_tests_others) { + $proxmox_install_runenv->redefine( + query_total_memory => sub { return $total_mem; }, + ); - mock_product('pmg'); - is(Proxmox::Install::RunEnv::default_zfs_arc_max(), $total_mem < 4096 ? $expected : 0, - "zfs_arc_max should default to `0` for PMG with $total_mem MiB system memory"); - - mock_product('pdm'); - is(Proxmox::Install::RunEnv::default_zfs_arc_max(), $total_mem < 2048 ? $expected : 0, - "zfs_arc_max should default to `0` for PDM with $total_mem MiB system memory"); + foreach my $product ('pbs', 'pmg', 'pdm') { + mock_product($product); + is(Proxmox::Install::RunEnv::default_zfs_arc_max(), $expected, + "zfs_arc_max should default to $expected for $product with $total_mem MiB system memory"); + } } my @clamp_tests = ( -- 2.48.1 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel