From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 0F94C1FF138 for ; Mon, 20 Jul 2026 14:39:29 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id A974421680; Mon, 20 Jul 2026 14:38:16 +0200 (CEST) From: Daniel Kral To: pve-devel@lists.proxmox.com Subject: [PATCH ha-manager 15/16] lrm: compute valid service uids hash set once per work iteration Date: Mon, 20 Jul 2026 14:37:04 +0200 Message-ID: <20260720123705.216089-16-d.kral@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260720123705.216089-1-d.kral@proxmox.com> References: <20260720123705.216089-1-d.kral@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1784551006650 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.232 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_LOW -0.7 Sender listed at https://www.dnswl.org/, low trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: JK46CZIHOKFDSI24A3ZQTQWF7VJTCXGE X-Message-ID-Hash: JK46CZIHOKFDSI24A3ZQTQWF7VJTCXGE X-MailFrom: d.kral@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The $self->{service_status} property is read-only and updated once per work iteration. This makes the recomputation on every resource command completion in resource_command_finished() unnecessary. In a test startup of 768 HA resources on a single node at the same time showed a ~2.5 speedup for resource_command_finished(). +---------------------------+---------------+--------------+ | Subroutine | Before Change | After Change | +---------------------------+---------------+--------------+ | check_active_workers | 11.6ms | 4.09ms | | resource_command_finished | 2.81ms | 1.09ms | +---------------------------+---------------+--------------+ The profiling was done on a physical host with Devel::NYTProf 6.14 [0]. [0] https://metacpan.org/pod/Devel::NYTProf Signed-off-by: Daniel Kral --- src/PVE/HA/LRM.pm | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/PVE/HA/LRM.pm b/src/PVE/HA/LRM.pm index 5f77580c..911672cb 100644 --- a/src/PVE/HA/LRM.pm +++ b/src/PVE/HA/LRM.pm @@ -47,6 +47,8 @@ sub new { # service_status from manager_status in current work() iteration # does contain all HA resources, users must filter for the assigned node service_status => {}, + # UIDs from the service_status in current work() iteration + service_status_uids => {}, # node_status from manager_status in current work() iteration # this is currently only used to check whether a fence for the node is requested # see $PVE::HA::NodeStatus::valid_node_states for possible values @@ -220,7 +222,8 @@ C> and C>. The internal LRM status properties that are updated are C, -C, C, and C. +C, C, C, and +C. Returns 1 if the update was successful, otherwise returns undef. @@ -237,7 +240,9 @@ sub update_lrm_status { return undef; } else { $self->{service_config} = $haenv->read_service_config(); - $self->{service_status} = $ms->{service_status} || {}; + my $ss = $ms->{service_status} || {}; + $self->{service_status} = $ss; + $self->{service_status_uids} = { map { $ss->{$_}->{uid} => 1 } keys %$ss }; my $nodename = $haenv->nodename(); $self->{node_status} = $ms->{node_status}->{$nodename} || 'unknown'; @@ -886,19 +891,9 @@ sub resource_command_finished { exit_code => $exit_code, }; - my $ss = $self->{service_status}; - - # compute hash of valid/existing uids - my $valid_uids = {}; - foreach my $sid (keys %$ss) { - my $sd = $ss->{$sid}; - next if !$sd->{uid}; - $valid_uids->{ $sd->{uid} } = 1; - } - my $results = {}; foreach my $id (keys %{ $self->{results} }) { - next if !$valid_uids->{$id}; + next if !$self->{service_status_uids}->{$id}; $results->{$id} = $self->{results}->{$id}; } $self->{results} = $results; -- 2.47.3