public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH manager/docs 0/4] fix #2413: make target for ballooning configurable
@ 2025-03-12 15:15 Friedrich Weber
  2025-03-12 15:15 ` [pve-devel] [PATCH manager 1/4] node: options: add config option for ballooning target Friedrich Weber
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Friedrich Weber @ 2025-03-12 15:15 UTC (permalink / raw)
  To: pve-devel

Automatic memory allocation (ballooning) is implemented in pvestatd, which
assigns memory to or reclaims memory from eligible VMs in order to reach a
certain target memory usage on the host. The target is currently hardcoded at
80%. Users have reported [1] that this target is unnecessarily low on hosts
with large amounts of RAM.

This patch series makes the ballooning target configurable. For this, it adds a
new node config option `ballooning-target`. pvestatd then reads the target from
that option.

Some potential discussion points:

- Is it OK to have this as a node option? I imagine some users may want to set
  different targets on different nodes. But other users may want to set one
  target for the whole cluster. Should we have a `ballooning-target` datacenter
  option that can be overridden by a `ballooning-target` node option? This might
  be overkill for such a simple option, though.

- Instead of a `ballooning-target` option, should we go for some general
  `ballooning-settings` with a property string like `target=80`, in case we want
  to make other values (such as `$maxchange`, which is currently hardcoded at 100
  MiB) configurable in the future too?

- In a mixed-version cluster where node 1 has this patch series and node 2
  doesn't yet, any attempt to change node 2's ballooning target from node 1's GUI
  will error out with `ballooning-target: property is not defined in schema`.
  This is not very nice, but not terrible either, as the error message is
  relatively descriptive. Still, is there an easy way to avoid this (checking
  client-side whether the option exists?)

[1] https://bugzilla.proxmox.com/show_bug.cgi?id=2413

manager:

Friedrich Weber (3):
  node: options: add config option for ballooning target
  fix #2413: pvestatd: read ballooning RAM usage target from node config
  ui: node options: allow editing the ballooning RAM usage target

 PVE/NodeConfig.pm                    |  8 ++++++++
 PVE/Service/pvestatd.pm              | 10 +++++++---
 www/manager6/node/NodeOptionsView.js | 18 ++++++++++++++++++
 3 files changed, 33 insertions(+), 3 deletions(-)


docs:

Friedrich Weber (1):
  pvenode: document ballooning-target node option

 pvenode.adoc | 13 +++++++++++++
 qm.adoc      | 13 ++++++++-----
 2 files changed, 21 insertions(+), 5 deletions(-)


Summary over all repositories:
  5 files changed, 54 insertions(+), 8 deletions(-)

-- 
Generated by git-murpp 0.7.3


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [pve-devel] [PATCH manager 1/4] node: options: add config option for ballooning target
  2025-03-12 15:15 [pve-devel] [PATCH manager/docs 0/4] fix #2413: make target for ballooning configurable Friedrich Weber
@ 2025-03-12 15:15 ` Friedrich Weber
  2025-03-12 15:15 ` [pve-devel] [PATCH manager 2/4] fix #2413: pvestatd: read ballooning RAM usage target from node config Friedrich Weber
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Friedrich Weber @ 2025-03-12 15:15 UTC (permalink / raw)
  To: pve-devel

The option is intended for the percentage of host memory that pvestatd
uses as the target for automatic memory allocation (ballooning).

Signed-off-by: Friedrich Weber <f.weber@proxmox.com>
---
 PVE/NodeConfig.pm | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/PVE/NodeConfig.pm b/PVE/NodeConfig.pm
index 5f58dff5..d9d83615 100644
--- a/PVE/NodeConfig.pm
+++ b/PVE/NodeConfig.pm
@@ -93,6 +93,14 @@ my $confdesc = {
 	default => 0,
 	optional => 1,
     },
+    'ballooning-target' => {
+	description => 'RAM usage target for ballooning (in percent of total memory)',
+	type => 'integer',
+	minimum => 0,
+	maximum => 100,
+	default => 80,
+	optional => 1,
+    },
 };
 
 my $wakeonlan_desc = {
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [pve-devel] [PATCH manager 2/4] fix #2413: pvestatd: read ballooning RAM usage target from node config
  2025-03-12 15:15 [pve-devel] [PATCH manager/docs 0/4] fix #2413: make target for ballooning configurable Friedrich Weber
  2025-03-12 15:15 ` [pve-devel] [PATCH manager 1/4] node: options: add config option for ballooning target Friedrich Weber
@ 2025-03-12 15:15 ` Friedrich Weber
  2025-03-12 15:15 ` [pve-devel] [PATCH manager 3/4] ui: node options: allow editing the ballooning RAM usage target Friedrich Weber
  2025-03-12 15:15 ` [pve-devel] [PATCH docs 4/4] pvenode: document ballooning-target node option Friedrich Weber
  3 siblings, 0 replies; 5+ messages in thread
From: Friedrich Weber @ 2025-03-12 15:15 UTC (permalink / raw)
  To: pve-devel

Currently, the automatic memory management (ballooning) performed by
pvestatd targets 80% memory usage. Users have reported that this
target is unnecessarily low on hosts with large amounts of RAM.

Thus, read the target from the node config option `ballooning-target`.
Also change the ballooning debug log output to include the target.

Signed-off-by: Friedrich Weber <f.weber@proxmox.com>
---
 PVE/Service/pvestatd.pm | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/PVE/Service/pvestatd.pm b/PVE/Service/pvestatd.pm
index 7fa003fe..d80c62da 100755
--- a/PVE/Service/pvestatd.pm
+++ b/PVE/Service/pvestatd.pm
@@ -15,6 +15,7 @@ use PVE::CpuSet;
 use Filesys::Df;
 use PVE::INotify;
 use PVE::Network;
+use PVE::NodeConfig;
 use PVE::Cluster qw(cfs_read_file);
 use PVE::Storage;
 use PVE::QemuServer;
@@ -215,9 +216,12 @@ sub auto_balloning {
     #$hostmeminfo->{memtotal} = int(2*1024*1024*1024/0.8); # you can set this to test
     my $hostfreemem = $hostmeminfo->{memtotal} - $hostmeminfo->{memused};
 
-    # try to use ~80% host memory; goal is the change amount required to achieve that
-    my $goal = int($hostmeminfo->{memtotal} * 0.8 - $hostmeminfo->{memused});
-    $log->("host goal: $goal free: $hostfreemem total: $hostmeminfo->{memtotal}\n");
+    # try to keep host memory usage at a certain percentage (= target), default is 80%
+    my $config = PVE::NodeConfig::load_config($nodename);
+    my $target = int($config->{'ballooning-target'} // 80);
+    # goal is the change amount required to achieve that
+    my $goal = int($hostmeminfo->{memtotal} * $target / 100 - $hostmeminfo->{memused});
+    $log->("target: $target%% host goal: $goal free: $hostfreemem total: $hostmeminfo->{memtotal}\n");
 
     my $maxchange = 100*1024*1024;
     my $res = PVE::AutoBalloon::compute_alg1($vmstatus, $goal, $maxchange);
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [pve-devel] [PATCH manager 3/4] ui: node options: allow editing the ballooning RAM usage target
  2025-03-12 15:15 [pve-devel] [PATCH manager/docs 0/4] fix #2413: make target for ballooning configurable Friedrich Weber
  2025-03-12 15:15 ` [pve-devel] [PATCH manager 1/4] node: options: add config option for ballooning target Friedrich Weber
  2025-03-12 15:15 ` [pve-devel] [PATCH manager 2/4] fix #2413: pvestatd: read ballooning RAM usage target from node config Friedrich Weber
@ 2025-03-12 15:15 ` Friedrich Weber
  2025-03-12 15:15 ` [pve-devel] [PATCH docs 4/4] pvenode: document ballooning-target node option Friedrich Weber
  3 siblings, 0 replies; 5+ messages in thread
From: Friedrich Weber @ 2025-03-12 15:15 UTC (permalink / raw)
  To: pve-devel

This corresponds to the `ballooning-target` node config option.

Also make the left column slightly wider, so the texts fit better.

Signed-off-by: Friedrich Weber <f.weber@proxmox.com>
---
 www/manager6/node/NodeOptionsView.js | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/www/manager6/node/NodeOptionsView.js b/www/manager6/node/NodeOptionsView.js
index 661c0e90..53443bfd 100644
--- a/www/manager6/node/NodeOptionsView.js
+++ b/www/manager6/node/NodeOptionsView.js
@@ -3,6 +3,8 @@ Ext.define('Proxmox.node.NodeOptionsView', {
     alias: ['widget.proxmoxNodeOptionsView'],
     mixins: ['Proxmox.Mixin.CBind'],
 
+    cwidth1: 250,
+
     cbindData: function(_initialconfig) {
 	let me = this;
 
@@ -64,5 +66,21 @@ Ext.define('Proxmox.node.NodeOptionsView', {
 		return value;
 	    },
 	},
+	{
+	    xtype: 'integer',
+	    name: 'ballooning-target',
+	    text: gettext('RAM usage target for ballooning'),
+	    minValue: 0,
+	    maxValue: 100,
+	    deleteEmpty: true,
+	    onlineHelp: 'qm_memory',
+	    renderer: function(value) {
+		if (value === undefined) {
+		    return gettext('Default (80%)');
+		}
+
+		return Ext.htmlEncode(`${value}%`);
+	    },
+	},
     ],
 });
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [pve-devel] [PATCH docs 4/4] pvenode: document ballooning-target node option
  2025-03-12 15:15 [pve-devel] [PATCH manager/docs 0/4] fix #2413: make target for ballooning configurable Friedrich Weber
                   ` (2 preceding siblings ...)
  2025-03-12 15:15 ` [pve-devel] [PATCH manager 3/4] ui: node options: allow editing the ballooning RAM usage target Friedrich Weber
@ 2025-03-12 15:15 ` Friedrich Weber
  3 siblings, 0 replies; 5+ messages in thread
From: Friedrich Weber @ 2025-03-12 15:15 UTC (permalink / raw)
  To: pve-devel

Also adjust the ballooning documentation to mention and
cross-reference this node option.

Signed-off-by: Friedrich Weber <f.weber@proxmox.com>
---
 pvenode.adoc | 13 +++++++++++++
 qm.adoc      | 13 ++++++++-----
 2 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/pvenode.adoc b/pvenode.adoc
index 21a46a8..f3e99ce 100644
--- a/pvenode.adoc
+++ b/pvenode.adoc
@@ -192,6 +192,19 @@ pvenode migrateall pve2 --vms 100,101,102 --with-local-disks
 
 // TODO: explain node shutdown (stopall is used there) and maintenance options
 
+[[ballooning-target]]
+RAM Usage Target for Ballooning
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The target percentage for xref:qm_ballooning[automatic memory allocation]
+defaults to 80%. You can customize this target per node by setting the
+`ballooning-target` property. For example, to target 90% host memory usage
+instead:
+
+----
+pvenode config set --ballooning-target 90
+----
+
 ifdef::manvolnum[]
 include::pve-copyright.adoc[]
 endif::manvolnum[]
diff --git a/qm.adoc b/qm.adoc
index 4bb8f2c..07ec5cf 100644
--- a/qm.adoc
+++ b/qm.adoc
@@ -697,13 +697,15 @@ it (like for debugging purposes), simply uncheck *Ballooning Device* or set
 
 in the configuration.
 
+[[qm_ballooning]]
 .Automatic Memory Allocation
 
 // see autoballoon() in pvestatd.pm
-When setting the minimum memory lower than memory, {pve} will make sure that the
-minimum amount you specified is always available to the VM, and if RAM usage on
-the host is below 80%, will dynamically add memory to the guest up to the
-maximum memory specified.
+When setting the minimum memory lower than memory, {pve} will make sure that
+the minimum amount you specified is always available to the VM, and if RAM
+usage on the host is below a certain target percentage, will dynamically add
+memory to the guest up to the maximum memory specified. The target percentage
+defaults to 80% and can be configured xref:ballooning-target[in the node options].
 
 When the host is running low on RAM, the VM will then release some memory
 back to the host, swapping running processes if needed and starting the oom
@@ -715,7 +717,8 @@ footnote:[A good explanation of the inner workings of the balloon driver can be
 When multiple VMs use the autoallocate facility, it is possible to set a
 *Shares* coefficient which indicates the relative amount of the free host memory
 that each VM should take. Suppose for instance you have four VMs, three of them
-running an HTTP server and the last one is a database server. To cache more
+running an HTTP server and the last one is a database server.
+The host is configured to target 80% RAM usage. To cache more
 database blocks in the database server RAM, you would like to prioritize the
 database VM when spare RAM is available. For this you assign a Shares property
 of 3000 to the database VM, leaving the other VMs to the Shares default setting
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-03-12 15:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-12 15:15 [pve-devel] [PATCH manager/docs 0/4] fix #2413: make target for ballooning configurable Friedrich Weber
2025-03-12 15:15 ` [pve-devel] [PATCH manager 1/4] node: options: add config option for ballooning target Friedrich Weber
2025-03-12 15:15 ` [pve-devel] [PATCH manager 2/4] fix #2413: pvestatd: read ballooning RAM usage target from node config Friedrich Weber
2025-03-12 15:15 ` [pve-devel] [PATCH manager 3/4] ui: node options: allow editing the ballooning RAM usage target Friedrich Weber
2025-03-12 15:15 ` [pve-devel] [PATCH docs 4/4] pvenode: document ballooning-target node option Friedrich Weber

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