From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 02E2B1FF0DE for ; Thu, 19 Nov 2026 14:52:52 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 727D92169C; Thu, 19 Nov 2026 14:52:49 +0100 (CET) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Thu, 19 Nov 2026 14:52:38 +0100 Message-Id: To: "Daniel Kral" , Subject: Re: [PATCH proxmox v2 06/19] fix #7993: resource-scheduling: scheduler: add weights From: "Dominik Rusovac" X-Mailer: aerc 0.20.0 References: <20261112094437.1951271-1-d.rusovac@proxmox.com> <20261112094437.1951271-7-d.rusovac@proxmox.com> In-Reply-To: X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1795096358521 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: BLX5PD2KJDWKFJBWF5NAZBA6OH2H4TSG X-Message-ID-Hash: BLX5PD2KJDWKFJBWF5NAZBA6OH2H4TSG 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: On Thu Nov 19, 2026 at 1:40 PM CET, Daniel Kral wrote: > On Thu Nov 12, 2026 at 10:44 AM CET, Dominik Rusovac wrote: >> CRS did not rebalance a cluster that was clearly imbalanced in CPU load >> or memory usage alone, because the combined node load looked balanced >> enough [0] >> >> add weights to the scheduler, so that callers can prioritize balancing >> one resource over the other >> >> load imbalance computations and the bruteforce method use the weighted >> node load >> >> for the TOPSIS methods, the weights replace the hardcoded criteria >> weights from commit 2b325aa5 ("add pve_static module"). those favor >> memory usage 5 times over CPU load. Scaling them with the weights >> instead would make the weights relative to that built-in emphasis, so >> 1:1 would effectively mean 1:5, which is undesirable. only the factor of >> 2 between the criteria for the highest and the average usage of each >> resource is kept, so custom weights of 1:5 reproduce the previous >> criteria weights of 1:5 (average) and 2:10 (highest) >> >> the same weights are used for the TOPSIS criteria and the node load, so >> the imbalance reported for the migrations ranked by TOPSIS is weighted >> like the criteria that ranked them >> >> the weights default to 1:1. This changes the default ranking of the >> TOPSIS methods (expected result of one affected test was adjusted), so >> callers have to pass hardcoded legacy topsis weights to keep their >> previous rankings. with these, the node load is weighted 1:5 as well and >> the previous rankings are preserved, which is also being tested >> >> [0] https://bugzilla.proxmox.com/show_bug.cgi?id=3D7993 >> >> Signed-off-by: Dominik Rusovac >> --- >> >> Notes: >> new with changes regarding patch [0] in v1: >> * add weights as field to Scheduler struct >> * weigh the TOPSIS criteria directly with the weights, keeping the f= actor >> of 2 between the highest and the average usage criteria of each re= source >> - weights of 1:5 reproduce the previous criteria weights 1, 2, 5, = 10 >> - add LEGACY_TOPSIS_WEIGHTS for callers keeping the previous ranki= ngs >> * fall back to previous TOPSIS ranking of migration candidates >> * no longer expose score and keep ScoredMigration as is >> * adjust one scheduler test's expected result >> * test that legacy topsis weights preserve previous rankings >> =20 >> [0] https://lore.proxmox.com/all/20261021085932.1196302-4-d.rusovac@= proxmox.com/ >> >> proxmox-resource-scheduling/src/pve_static.rs | 4 +- >> proxmox-resource-scheduling/src/scheduler.rs | 105 ++++++++++++++---- >> .../tests/scheduler.rs | 64 ++++++++++- >> 3 files changed, 149 insertions(+), 24 deletions(-) [snip] >> - const N_CRITERIA; >> - static PVE_HA_TOPSIS_CRITERIA; >> +/// Factor to compute the weight of the criterion for the highest usage= of a resource relative to >> +/// the criterion for the average usage of that resource. This keeps th= e ratio of the criteria >> +/// weights introduced in commit 2b325aa5. > > nit: include the commit title here, i.e. > > 2b325aa5 ("add pve_static module") > ack >> +/// >> +/// For more details see [`topsis_criteria`]. >> +const TOPSIS_HIGHEST_USAGE_FACTOR: f64 =3D 2.0; >> + >> +/// Weights that reproduce the TOPSIS criteria weights introduced in co= mmit 2b325aa5 with > > here as well > ack >> +/// [`topsis_criteria`]. >> +pub const LEGACY_TOPSIS_WEIGHTS: NodeStatsWeights =3D NodeStatsWeights = { >> + cpu_weight: 1.0, >> + mem_weight: 5.0, >> +}; >> + >> +/// Returns the TOPSIS criteria for a [`PveTopsisAlternative`], weighte= d by `weights`. >> +/// >> +/// The criteria for the average usage of each resource get the respect= ive weight in `weights`, >> +/// the criteria for the highest usage get [`TOPSIS_HIGHEST_USAGE_FACTO= R`] times that weight. >> +fn topsis_criteria(weights: &NodeStatsWeights) -> Result, Error> { > > nit: topsis_criteria_from_weights() or make this a method of Scheduler, > which is its only user > I had `topsis_criteria_from_weights` at some point, can go back to it [snip] >> fn new_empty_cluster_scheduler() -> Scheduler { >> @@ -317,7 +317,7 @@ fn test_score_homogeneous_nodes_to_start_resource() = -> Result<(), Error> { > > is the scheduler here intentionally not augmented with > > .with_weights(LEGACY_TOPSIS_WEIGHTS) ? > yes, the existing tests are meant to check the default (equal) weights, while test_legacy_topsis_weights_keep_unweighted_rankings covers the legacy weights=20 good catch tho, using the weights for the heterogeneous one is inconsistent with that, will drop it there and adapt its expected rankings in v3 >> =20 >> assert_eq!( >> rank_nodes_to_start_resource(&scheduler, combined_resource_stat= s)?, >> - vec!["node2", "node3", "node1"] >> + vec!["node1", "node3", "node2"] >> ); >> =20 >> Ok(()) >> @@ -325,7 +325,7 @@ fn test_score_homogeneous_nodes_to_start_resource() = -> Result<(), Error> { >> =20 >> #[test] >> fn test_score_heterogeneous_nodes_to_start_resource() -> Result<(), Err= or> { >> - let scheduler =3D new_heterogeneous_cluster_scheduler(); >> + let scheduler =3D new_heterogeneous_cluster_scheduler().with_weight= s(LEGACY_TOPSIS_WEIGHTS); >> =20 will drop it here ^ [snip]