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 587051FF0DE for ; Thu, 19 Nov 2026 14:28:19 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 5748121696; Thu, 19 Nov 2026 14:28:17 +0100 (CET) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Thu, 19 Nov 2026 14:28:11 +0100 Message-Id: Subject: Re: [PATCH proxmox-perl-rs v2 09/19] fix #7993: pve-rs: resource-scheduling: add scheduler options From: "Dominik Rusovac" To: "Daniel Kral" , X-Mailer: aerc 0.20.0 References: <20261112094437.1951271-1-d.rusovac@proxmox.com> <20261112094437.1951271-10-d.rusovac@proxmox.com> In-Reply-To: X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1795094891677 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.024 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_MED -2.3 Sender listed at https://www.dnswl.org/, medium 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: K4S2EJEHPRG4CDQNT7GPFD7NXYIF3W7T X-Message-ID-Hash: K4S2EJEHPRG4CDQNT7GPFD7NXYIF3W7T 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: thx for your review! On Thu Nov 19, 2026 at 1:45 PM CET, Daniel Kral wrote: > On Thu Nov 12, 2026 at 10:44 AM CET, Dominik Rusovac wrote: >> allow passing options to the constructor of the static and dynamic >> scheduler, which specify the weights of the CPU load and memory usage >> applied to every load balancing computation. these options are a single >> optional parameter with only optional fields, so the signatures of the >> existing methods stay the same >> >> with specified weights, every rebalancing method uses them for the load >> imbalance and the TOPSIS criteria alike, so that for example 1:1 means >> 1:1 for every method. weights of 1:5 reproduce the previous TOPSIS >> criteria weights >> >> without specified weights, every method keeps its previous behavior: the >> load imbalance and the bruteforce method use equal weights (1:1); the >> TOPSIS methods use weights of 1:5 for their criteria >> >> NOTE: weights are not validated. if both are 0, there is simply no load >> imbalance and the TOPSIS methods fail, so callers must not pass such >> weights >> >> NOTE: to decide whether a migration improves the balance enough, the HA >> manager compares the load imbalance reported for the migrations ranked >> by TOPSIS with the current load imbalance. without specified weights, >> the TOPSIS ranking would report an imbalance weighted 1:5, while the >> load imbalance is unweighted. so, without specified weights, recompute >> the reported imbalance of the ranked migrations with equal weights, as >> before. while this requires reiterating all migrations candidates, it is >> required to keep older versions of the HA manager working as before by >> preventing them from running into this undesirable load imbalance >> mismatch >> >> add test cases checking that: >> - without options or with unspecified options, the load imbalance and >> the node scores stay the same as before >> - equal weights keep the unweighted load imbalance, regardless of their >> magnitude >> - weights of 1:5 keep the previous node scores, but change the load >> imbalance, as it's also being weighted 1:5 >> - weighting only the CPU load or only the memory usage results in a >> different load imbalance >> - the TOPSIS ranking reports the same load imbalance as the bruteforce >> method, both without specified options and with weights of 1:5, as the >> HA manager compares it with the current load imbalance >> - without specified options, the TOPSIS ranking is the same as with >> weights of 1:5 >> - the dynamic scheduler accepts options as well >> >> Signed-off-by: Dominik Rusovac >> --- >> >> Notes: >> changes since v1: >> * reword commit >> * pass the weights once as optional scheduler options to the constru= ctor >> instead of adding weight parameters to every method, as suggested = in >> the review of v1, so the signatures of the existing methods stay t= he >> same and older HA manager versions can still call them >> * options are a single optional hash with only optional fields, a >> missing weight defaults to 1 >> * without options, every method keeps its previous behavior, includi= ng >> the TOPSIS ranking with weights of 1:5 >> * without options, recompute the imbalance reported with the TOPSIS >> ranking with equal weights, so that it stays comparable to the nod= e >> imbalance for older HA manager version >> * weights also apply to score_nodes_to_start_service() >> * drop the adjustment of the existing test, as calling the methods >> without weights keeps working >> * add test cases for the scheduler options >> =20 >> requires the proxmox-resource-scheduling patches of this series >> >> .../src/bindings/resource_scheduling/mod.rs | 1 + >> .../bindings/resource_scheduling/options.rs | 59 ++++++++ >> .../resource_scheduling/pve_dynamic.rs | 71 +++++++-- >> .../resource_scheduling/pve_static.rs | 64 ++++++-- >> pve-rs/test/resource_scheduling.pl | 141 ++++++++++++++++++ >> 5 files changed, 304 insertions(+), 32 deletions(-) >> create mode 100644 pve-rs/src/bindings/resource_scheduling/options.rs [snip] >> diff --git a/pve-rs/src/bindings/resource_scheduling/pve_dynamic.rs b/pv= e-rs/src/bindings/resource_scheduling/pve_dynamic.rs >> index 8e066e0..62d6426 100644 >> --- a/pve-rs/src/bindings/resource_scheduling/pve_dynamic.rs >> +++ b/pve-rs/src/bindings/resource_scheduling/pve_dynamic.rs >> @@ -12,11 +12,16 @@ pub mod pve_rs_resource_scheduling_dynamic { >> use serde::{Deserialize, Serialize}; >> =20 >> use perlmod::Value; >> - use proxmox_resource_scheduling::node::NodeStats; >> + use proxmox_resource_scheduling::node::{NodeStats, NodeStatsWeights= }; >> use proxmox_resource_scheduling::resource::ResourceStats; >> - use proxmox_resource_scheduling::scheduler::ScoredMigration; >> - use proxmox_resource_scheduling::usage::Usage; >> + use proxmox_resource_scheduling::scheduler::{ >> + LEGACY_TOPSIS_WEIGHTS, Scheduler as CoreScheduler, ScoredMigrat= ion, >> + }; >> + use proxmox_resource_scheduling::usage::{Usage, UsageAggregator}; >> =20 >> + use crate::bindings::resource_scheduling::options::{ >> + SchedulerOptions, with_unweighted_imbalance, >> + }; >> use crate::bindings::resource_scheduling::resource::{ >> CompactMigrationCandidate, PveResource, decompose_compact_migra= tion_candidates, >> }; >> @@ -29,6 +34,21 @@ pub mod pve_rs_resource_scheduling_dynamic { >> /// A scheduler instance contains the cluster usage. >> pub struct Scheduler { >> inner: Mutex, >> + weights: Option, >> + } >> + >> + impl Scheduler { >> + /// Returns a scheduler for the current `usage`, aggregated by = `F`, with the weights of >> + /// this instance or `default_weights` if this instance has non= e. >> + fn to_weighted_scheduler( >> + &self, >> + usage: &Usage, >> + default_weights: NodeStatsWeights, >> + ) -> CoreScheduler { >> + usage >> + .to_scheduler::() >> + .with_weights(self.weights.unwrap_or(default_weights)) >> + } > > Hm, not a big one, but this could also just live in > proxmox_resource_scheduling itself, where Usage implements a > > pub fn to_weighted_scheduler(&self, weights: Node= StatsWeights) -> Scheduler { > let node_usages =3D F::aggregate(self); > > Scheduler::from_nodes(node_usages).with_weights(weights) > } > > and then the unwrap_or() could be made explicitly where it's called to > it's clear that it's a default fallback in there. > technically, yes, but I'd rather keep it in proxmox-perl-rs > No hard feelings though. just to give my 2 cents on why I'd rather keep it there the `weights` are only optional in there, because the bindings can be constructed without scheduler options, so that older HA managers keep working. in contrast, proxmox-resource-scheduling's scheduler always has weights, so the `unwrap_or` call would stay in the bindings either way, and on the proxmox-resource-scheduling side usage.to_scheduler::().with_weights(weights) already does the same as the proposed method also, the fallback is already explicit where the helper is called, as each caller passes its default weights [snip]