public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH qemu-server] qemu options: add memory_allocator
@ 2023-03-13 10:16 Alexandre Derumier
  2023-03-13 17:09 ` Thomas Lamprecht
  0 siblings, 1 reply; 2+ messages in thread
From: Alexandre Derumier @ 2023-03-13 10:16 UTC (permalink / raw)
  To: pve-devel

Add optional memory_allocator.

Default is glibc malloc, tcmalloc is available to improve performance
of ceph librbd.

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
---
 PVE/QemuServer.pm | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 40be44d..8de6c82 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -723,6 +723,14 @@ EODESCR
 	description => "List of host cores used to execute guest processes, for example: 0,5,8-11",
 	optional => 1,
     },
+    memory_allocator => {
+	optional => 1,
+	type => 'string',
+	enum => [ qw(glibc tcmalloc) ],
+	default => 'glibc',
+	description => "Configure qemu process memory allocator. tcmalloc improve performance of ceph librbd",
+	optional => 1,
+    },
 };
 
 my $cicustom_fmt = {
@@ -5909,6 +5917,10 @@ sub vm_start_nolock {
 
     my $run_qemu = sub {
 	PVE::Tools::run_fork sub {
+
+	    $ENV{LD_PRELOAD} = "/usr/lib/x86_64-linux-gnu/libtcmalloc.so.4"
+		if $conf->{memory_allocator} && $conf->{memory_allocator} eq 'tcmalloc';
+
 	    PVE::Systemd::enter_systemd_scope($vmid, "Proxmox VE VM $vmid", %systemd_properties);
 
 	    my $tpmpid;
-- 
2.30.2




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

* Re: [pve-devel] [PATCH qemu-server] qemu options: add memory_allocator
  2023-03-13 10:16 [pve-devel] [PATCH qemu-server] qemu options: add memory_allocator Alexandre Derumier
@ 2023-03-13 17:09 ` Thomas Lamprecht
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2023-03-13 17:09 UTC (permalink / raw)
  To: Proxmox VE development discussion, Alexandre Derumier

Am 13/03/2023 um 11:16 schrieb Alexandre Derumier:
> Add optional memory_allocator.
> 
> Default is glibc malloc, tcmalloc is available to improve performance
> of ceph librbd.

Looks ok besides some config/api schema details I'd like to see changed.

> 
> Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
> ---
>  PVE/QemuServer.pm | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
> index 40be44d..8de6c82 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
> @@ -723,6 +723,14 @@ EODESCR
>  	description => "List of host cores used to execute guest processes, for example: 0,5,8-11",
>  	optional => 1,
>      },
> +    memory_allocator => {

kebab-case for new properties please, but actually I'd like to have this nested
in a property string here, e.g.:

tuning => {
    optional => 1,
    type => 'string',
    format => { # <- probably in a $tuning_format variable
        allocator => {
             # ...
        },
    }
}

> +	optional => 1,
> +	type => 'string',
> +	enum => [ qw(glibc tcmalloc) ],

system tcmalloc

> +	default => 'glibc',
> +	description => "Configure qemu process memory allocator. tcmalloc improve performance of ceph librbd",

I'd change this to:

description => "Override the memory allocator used in QEMU via LD_PRELOAD.",
verbose_description => "Override the memory allocator used in QEMU via LD_PRELOAD."
    ." Using tcmalloc might improve performance if ceph librbd is used.",
    ." NOTE: you must install the libtcmalloc-minimal4 package first!"

> +	optional => 1,

you got "optional" set to true twice

> +    },
>  };
>  
>  my $cicustom_fmt = {
> @@ -5909,6 +5917,10 @@ sub vm_start_nolock {
>  
>      my $run_qemu = sub {
>  	PVE::Tools::run_fork sub {
> +
> +	    $ENV{LD_PRELOAD} = "/usr/lib/x86_64-linux-gnu/libtcmalloc.so.4"
> +		if $conf->{memory_allocator} && $conf->{memory_allocator} eq 'tcmalloc';
> +
>  	    PVE::Systemd::enter_systemd_scope($vmid, "Proxmox VE VM $vmid", %systemd_properties);
>  
>  	    my $tpmpid;





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

end of thread, other threads:[~2023-03-13 17:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-13 10:16 [pve-devel] [PATCH qemu-server] qemu options: add memory_allocator Alexandre Derumier
2023-03-13 17:09 ` Thomas Lamprecht

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