From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id E84BC9269A for ; Tue, 21 Mar 2023 17:44:56 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id C55A81C3D6 for ; Tue, 21 Mar 2023 17:44:56 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Tue, 21 Mar 2023 17:44:55 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 4BB0245D84 for ; Tue, 21 Mar 2023 17:44:55 +0100 (CET) From: Fiona Ebner To: pve-devel@lists.proxmox.com Date: Tue, 21 Mar 2023 17:44:50 +0100 Message-Id: <20230321164452.268358-1-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.002 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% 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 Subject: [pve-devel] [PATCH proxmox-resource-scheduling] pve static: add one to avoid boosting tiny relative differences X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Mar 2023 16:44:57 -0000 Only the relative difference for values between different alternatives is relevant, meaning 0.002 vs 0.004 and 0.2 vs 0.4 will influence the scoring in the same way. This is not really desirable, because values closer to 1.0 indicate higher load and thus should influence the scoring more than differences that are actually tiny, but big when viewed as a relative difference. To avoid the issue, simply add 1.0 to all values. Like that, 1.002 vs 1.004 will also be small when viewed as a relative difference. Signed-off-by: Fiona Ebner --- src/pve_static.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/pve_static.rs b/src/pve_static.rs index 814d44f..d39614c 100644 --- a/src/pve_static.rs +++ b/src/pve_static.rs @@ -104,11 +104,13 @@ pub fn score_nodes_to_start_service( squares_mem += new_mem.powi(2); } + // Add 1.0 to avoid boosting tiny differences: e.g. 0.004 is twice as much as 0.002, but + // 1.004 is only slightly more than 1.002. PveTopsisAlternative { - average_cpu: (squares_cpu / len as f64).sqrt(), - highest_cpu, - average_memory: (squares_mem / len as f64).sqrt(), - highest_memory: highest_mem, + average_cpu: 1.0 + (squares_cpu / len as f64).sqrt(), + highest_cpu: 1.0 + highest_cpu, + average_memory: 1.0 + (squares_mem / len as f64).sqrt(), + highest_memory: 1.0 + highest_mem, } .into() }) -- 2.30.2