From: Christoph Heiss <c.heiss@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH installer 1/3] run env: always return proper value for default zfs max arc size
Date: Fri, 4 Apr 2025 14:46:46 +0200 [thread overview]
Message-ID: <20250404124651.1283950-2-c.heiss@proxmox.com> (raw)
In-Reply-To: <20250404124651.1283950-1-c.heiss@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
next prev parent reply other threads:[~2025-04-04 12:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-04 12:46 [pve-devel] [PATCH installer 0/3] fix #6285: always set up zfs modprobe configuration Christoph Heiss
2025-04-04 12:46 ` Christoph Heiss [this message]
2025-04-04 12:46 ` [pve-devel] [PATCH installer 2/3] tui: bootdisk: always return proper value for default zfs max arc size Christoph Heiss
2025-04-04 12:46 ` [pve-devel] [PATCH installer 3/3] fix #6285: install: always set up zfs modprobe configuration Christoph Heiss
2025-04-04 13:01 ` [pve-devel] applied-series: [PATCH installer 0/3] fix #6285: " Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250404124651.1283950-2-c.heiss@proxmox.com \
--to=c.heiss@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal