From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id E022B1FF140 for ; Fri, 27 Mar 2026 15:15:13 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 556C6C793; Fri, 27 Mar 2026 15:15:37 +0100 (CET) Content-Type: text/plain; charset=UTF-8 Date: Fri, 27 Mar 2026 15:15:02 +0100 Message-Id: Subject: Re: [PATCH perl-rs v2 15/40] pve-rs: resource-scheduling: implement pve_dynamic bindings From: "Dominik Rusovac" To: "Daniel Kral" , Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 X-Mailer: aerc 0.20.0 References: <20260324183029.1274972-1-d.kral@proxmox.com> <20260324183029.1274972-16-d.kral@proxmox.com> In-Reply-To: <20260324183029.1274972-16-d.kral@proxmox.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1774620852870 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.290 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: DXBZHONTQ4TXYZI3XCPGSIUOZJ7LJQJ2 X-Message-ID-Hash: DXBZHONTQ4TXYZI3XCPGSIUOZJ7LJQJ2 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 X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: lgtm, consider modulo one nit On Tue Mar 24, 2026 at 7:29 PM CET, Daniel Kral wrote: > The implementation is similar to pve_static, but extends the node and > resource stats with sampled runtime usage statistics, i.e., the actual > usage on the nodes and the actual usages of the resources. > > In the case of users repeatedly calling score_nodes_to_start_resource() > and then adding them as starting resources with add_resource(), these > starting resources need to be accumulated on top of these nodes actual > current usages to prevent score_nodes_to_start_resource() to favor the > currently least loaded node(s) for all starting resources. > > Signed-off-by: Daniel Kral > --- > changes v1 -> v2: > - move this patch one before 'expose auto rebalancing methods' as this > is the same change order as done in pve-ha-manager, making it easier > to separate the feature of using dynamic usage information and > afterwards allowing rebalancing methods with static and dynamic usage > information > - adapt patch message accordingly > - s/service/resource/ for any new struct and method as this is more > consistent with the naming in the HA Manager and the name of the > crate/module itself; can change this back if it's better in the other > way, but as these are new API endpoints, I thought it's better to do > it now than later > [snip] > +impl UsageAggregator for StartingAsStartedResourceAggregator { > + fn aggregate(usage: &Usage) -> Vec { > + usage > + .nodes_iter() > + .map(|(nodename, node)| { nice fold! nit: by making `node_stats` mutable in the first place, variable shadowing can be avoided, see: let stats =3D node.resources_iter().fold(node.stats(), |mut node_stats,= sid| { =20 if let Some(resource) =3D usage.get_resource(sid) { node_stats.add_started_resource(&resource.stats()); } =20 node_stats }); > + let stats =3D node.resources_iter().fold(node.stats(), |= node_stats, sid| { > + let mut node_stats =3D node_stats; > + > + if let Some(resource) =3D usage.get_resource(sid) > + && resource.state() =3D=3D ResourceState::Starti= ng > + { > + node_stats.add_started_resource(&resource.stats(= )); > + } > + > + node_stats > + }); > + > + NodeUsage { > + name: nodename.to_string(), > + stats, > + } > + }) > + .collect() > + } > +} Reviewed-by: Dominik Rusovac