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 B13971FF164 for <inbox@lore.proxmox.com>; Fri, 28 Feb 2025 10:44:28 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 9CD219978; Fri, 28 Feb 2025 10:44:23 +0100 (CET) From: Christoph Heiss <c.heiss@proxmox.com> To: pve-devel@lists.proxmox.com Date: Fri, 28 Feb 2025 10:43:36 +0100 Message-ID: <20250228094341.147783-2-c.heiss@proxmox.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250228094341.147783-1-c.heiss@proxmox.com> References: <20250228094341.147783-1-c.heiss@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.024 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 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. 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] URIBL_SBL_A 0.1 Contains URL's A record listed in the Spamhaus SBL blocklist [185.199.111.153, 185.199.110.153] Subject: [pve-devel] [PATCH installer 1/4] run env: provide default ZFS ARC maximum size value 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> This can be then used by the Rust parts directly, without having to duplicate the calculation. Signed-off-by: Christoph Heiss <c.heiss@proxmox.com> --- Proxmox/Install/RunEnv.pm | 10 +++++++--- test/zfs-arc-max.pl | 12 ++---------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/Proxmox/Install/RunEnv.pm b/Proxmox/Install/RunEnv.pm index 701343d..407d05c 100644 --- a/Proxmox/Install/RunEnv.pm +++ b/Proxmox/Install/RunEnv.pm @@ -238,6 +238,7 @@ my sub detect_country_tracing_to : prototype($$) { # hvm_supported = <1 if the CPU supports hardware-accelerated virtualization>, # secure_boot = <1 if SecureBoot is enabled>, # boot_type = <either 'efi' or 'bios'>, +# default_zfs_arc_max => <default upper limit for the ZFS ARC size in MiB>, # disks => <see Proxmox::Sys::Block::hd_list()>, # network => { # interfaces => <see query_netdevs()>, @@ -285,6 +286,7 @@ sub query_installation_environment : prototype() { $output->{total_memory} = query_total_memory(); $output->{hvm_supported} = query_cpu_hvm_support(); $output->{boot_type} = -d '/sys/firmware/efi' ? 'efi' : 'bios'; + $output->{default_zfs_arc_max} = default_zfs_arc_max(); if ($output->{boot_type} eq 'efi') { my $content = eval { file_read_all("/sys/firmware/efi/efivars/SecureBoot-8be4df61-93ca-11d2-aa0d-00e098032b8c") }; @@ -329,9 +331,11 @@ our $ZFS_ARC_SYSMEM_PERCENTAGE = 0.1; # use 10% of available system memory by de # Calculates the default upper limit for the ZFS ARC size. # Returns the default ZFS maximum ARC size in MiB. +# See also <https://bugzilla.proxmox.com/show_bug.cgi?id=4829> and +# https://openzfs.github.io/openzfs-docs/Performance%20and%20Tuning/Module%20Parameters.html#zfs-arc-max sub default_zfs_arc_max { my $product = Proxmox::Install::ISOEnv::get('product'); - my $total_memory = get('total_memory'); + 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. @@ -340,7 +344,7 @@ sub default_zfs_arc_max { return 0 if $total_memory >= 4096; # PMG's base memory requirement is much higer } - my $default_mib = get('total_memory') * $ZFS_ARC_SYSMEM_PERCENTAGE; + my $default_mib = $total_memory * $ZFS_ARC_SYSMEM_PERCENTAGE; my $rounded_mib = int(sprintf('%.0f', $default_mib)); if ($rounded_mib > $ZFS_ARC_MAX_SIZE_MIB) { @@ -361,7 +365,7 @@ sub clamp_zfs_arc_max { return $mib if $mib == 0; # upper limit is total system memory with a GiB headroom for the base system - my $total_mem_with_headroom_mib = get('total_memory') - 1024; + my $total_mem_with_headroom_mib = query_total_memory() - 1024; if ($mib > $total_mem_with_headroom_mib) { $mib = $total_mem_with_headroom_mib; # do not return directly here, to catch < min ARC size } diff --git a/test/zfs-arc-max.pl b/test/zfs-arc-max.pl index 6ae6356..8cf093f 100755 --- a/test/zfs-arc-max.pl +++ b/test/zfs-arc-max.pl @@ -33,11 +33,7 @@ my %default_tests = ( while (my ($total_mem, $expected) = each %default_tests) { $proxmox_install_runenv->redefine( - get => sub { - my ($k) = @_; - return $total_mem if $k eq 'total_memory'; - die "runtime environment key $k not mocked!\n"; - }, + query_total_memory => sub { return $total_mem; }, ); mock_product('pve'); @@ -71,11 +67,7 @@ foreach (@clamp_tests) { my ($input, $total_mem, $expected) = @$_; $proxmox_install_runenv->redefine( - get => sub { - my ($k) = @_; - return $total_mem if $k eq 'total_memory'; - die "runtime environment key $k not mocked!\n"; - }, + query_total_memory => sub { return $total_mem; }, ); is(Proxmox::Install::RunEnv::clamp_zfs_arc_max($input), $expected, -- 2.47.1 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel