From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id A2B8A1FF13C for ; Thu, 19 Mar 2026 10:15:20 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 41ED91438A; Thu, 19 Mar 2026 10:15:34 +0100 (CET) Content-Type: text/plain; charset=UTF-8 Date: Thu, 19 Mar 2026 10:15:27 +0100 Message-Id: Subject: Re: [RFC ha-manager 16/21] sim: hardware: add set-dynamic-stats for services From: "Dominik Rusovac" To: "Thomas Lamprecht" Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Mailer: aerc 0.20.0 References: <20260217141437.584852-1-d.kral@proxmox.com> <20260217141437.584852-30-d.kral@proxmox.com> <42858bd4-6d25-4d38-ba20-b1f2b9c5a208@proxmox.com> In-Reply-To: <42858bd4-6d25-4d38-ba20-b1f2b9c5a208@proxmox.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1773911685133 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.368 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment 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: 3BTZAPIKHTXOPL46N6UTWBBXWEXDRRK2 X-Message-ID-Hash: 3BTZAPIKHTXOPL46N6UTWBBXWEXDRRK2 X-MailFrom: d.rusovac@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 CC: pve-devel@lists.proxmox.com X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Wed Mar 18, 2026 at 11:34 PM CET, Thomas Lamprecht wrote: [snip]=20 > FWIW, we could avoid some code duplication between dynamic and static set > and reduce the test cmd's needed by applying something like below on top = at > this point. > > The change below basically leverage's the rather fresh perl 5.40's "for l= oop > with multiple iteration variables" [0] (which is fine to use for PVE 9, w= e > won't backport this to PVE 8 - where the perl version would be to old - a= nyway), > and merging the two branches for set-static-stats and set-dynamic-stats c= ommands > by using a hash for mapping the conversions of the different stats/cmds (= could > be written maybe even nicer). > > Then such chains like: > > info 220 cmdlist: execute service vm:103 set-dynamic-stats cpu 3.= 9=20 > info 220 cmdlist: execute service vm:103 set-dynamic-stats mem 65= 17 > info 220 cmdlist: execute service vm:104 set-dynamic-stats cpu 6.= 7=20 > info 220 cmdlist: execute service vm:104 set-dynamic-stats mem 80= 01 > info 220 cmdlist: execute service vm:105 set-dynamic-stats cpu 1.= 8=20 > info 220 cmdlist: execute service vm:105 set-dynamic-stats mem 12= 01 > info 220 cmdlist: execute service vm:106 set-dynamic-stats cpu 2.= 1=20 > info 220 cmdlist: execute service vm:106 set-dynamic-stats mem 12= 11 > info 220 cmdlist: execute service vm:107 set-dynamic-stats cpu 0.= 9=20 > info 220 cmdlist: execute service vm:107 set-dynamic-stats mem 11= 91 > > could become: > > info 220 cmdlist: execute service vm:103 set-dynamic-stats cpu 3.= 9 mem 6517 > info 220 cmdlist: execute service vm:104 set-dynamic-stats cpu 6.= 7 mem 8001 > info 220 cmdlist: execute service vm:105 set-dynamic-stats cpu 1.= 8 mem 1201 > info 220 cmdlist: execute service vm:106 set-dynamic-stats cpu 2.= 1 mem 1211 > info 220 cmdlist: execute service vm:107 set-dynamic-stats cpu 0.= 9 mem 1191 > > I.e., get basically cut in half without really loosing expressiveness (IM= O). > > [0]: https://perldoc.perl.org/perlexperiment#for-loop-with-multiple-itera= tion-variables Good idea, thx, will do!