From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 467AE9B22 for ; Fri, 18 Nov 2022 12:32:29 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 2C74737E4A for ; Fri, 18 Nov 2022 12:32:29 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Fri, 18 Nov 2022 12:32:27 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 8B35944D45 for ; Fri, 18 Nov 2022 12:32:27 +0100 (CET) From: Fiona Ebner To: pve-devel@lists.proxmox.com Date: Fri, 18 Nov 2022 12:32:21 +0100 Message-Id: <20221118113223.49305-2-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221118113223.49305-1-f.ebner@proxmox.com> References: <20221118113223.49305-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: =?UTF-8?Q?0=0A=09?=AWL 0.027 Adjusted score from AWL reputation of From: =?UTF-8?Q?address=0A=09?=BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict =?UTF-8?Q?Alignment=0A=09?=SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF =?UTF-8?Q?Record=0A=09?=SPF_PASS -0.001 SPF: sender matches SPF =?UTF-8?Q?record=0A=09?=URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [pvect.pm, resources.pm, pvevm.pm] Subject: [pve-devel] [RFC ha-manager 1/3] resources: get static stats: add cache parameter X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Nov 2022 11:32:29 -0000 so callers can avoid the overhead from load_config() if they already have the required information. Signed-off-by: Fiona Ebner --- src/PVE/HA/Resources.pm | 2 +- src/PVE/HA/Resources/PVECT.pm | 4 ++-- src/PVE/HA/Resources/PVEVM.pm | 5 +++-- src/PVE/HA/Sim/Resources.pm | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/PVE/HA/Resources.pm b/src/PVE/HA/Resources.pm index 7ba90f6..ee8de52 100644 --- a/src/PVE/HA/Resources.pm +++ b/src/PVE/HA/Resources.pm @@ -162,7 +162,7 @@ sub remove_locks { } sub get_static_stats { - my ($class, $haenv, $id, $service_node) = @_; + my ($class, $haenv, $id, $service_node, $cache) = @_; die "implement in subclass"; } diff --git a/src/PVE/HA/Resources/PVECT.pm b/src/PVE/HA/Resources/PVECT.pm index e77d98c..c10d024 100644 --- a/src/PVE/HA/Resources/PVECT.pm +++ b/src/PVE/HA/Resources/PVECT.pm @@ -153,9 +153,9 @@ sub remove_locks { } sub get_static_stats { - my ($class, $haenv, $id, $service_node) = @_; + my ($class, $haenv, $id, $service_node, $cache) = @_; - my $conf = PVE::LXC::Config->load_config($id, $service_node); + my $conf = $cache->{$id} ||= PVE::LXC::Config->load_config($id, $service_node); return { maxcpu => $conf->{cpulimit} || $conf->{cores} || 0, diff --git a/src/PVE/HA/Resources/PVEVM.pm b/src/PVE/HA/Resources/PVEVM.pm index f405d86..ca7fbc4 100644 --- a/src/PVE/HA/Resources/PVEVM.pm +++ b/src/PVE/HA/Resources/PVEVM.pm @@ -176,9 +176,10 @@ sub remove_locks { } sub get_static_stats { - my ($class, $haenv, $id, $service_node) = @_; + my ($class, $haenv, $id, $service_node, $cache) = @_; + + my $conf = $cache->{$id} ||= PVE::QemuConfig->load_config($id, $service_node); - my $conf = PVE::QemuConfig->load_config($id, $service_node); my $defaults = PVE::QemuServer::load_defaults(); my $cpus = ($conf->{sockets} || $defaults->{sockets}) * ($conf->{cores} || $defaults->{cores}); diff --git a/src/PVE/HA/Sim/Resources.pm b/src/PVE/HA/Sim/Resources.pm index e6e1853..999a77a 100644 --- a/src/PVE/HA/Sim/Resources.pm +++ b/src/PVE/HA/Sim/Resources.pm @@ -140,7 +140,7 @@ sub remove_locks { } sub get_static_stats { - my ($class, $haenv, $id, $service_node) = @_; + my ($class, $haenv, $id, $service_node, $cache) = @_; my $sid = $class->type() . ":$id"; my $hardware = $haenv->hardware(); -- 2.30.2