all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: "Dominik Rusovac" <d.rusovac@proxmox.com>
To: "Daniel Kral" <d.kral@proxmox.com>, <pve-devel@lists.proxmox.com>
Subject: Re: [PATCH pve-ha-manager v2 18/19] fix #7993: manager,usage: use weights for static and dynamic mode
Date: Mon, 23 Nov 2026 15:00:40 +0100	[thread overview]
Message-ID: <DN2N86N8FNQC.2U5BJTA1QQKI4@proxmox.com> (raw)
In-Reply-To: <DN2LMRITDXV8.32AP6AQ44WKGA@proxmox.com>

thx for the review!

On Mon Nov 23, 2026 at 1:45 PM CET, Daniel Kral wrote:
> On Thu Nov 12, 2026 at 10:44 AM CET, Dominik Rusovac wrote:
>> pass the ha-cpu-weight and ha-mem-weight CRS options to the static and
>> dynamic scheduler, so that users can prioritize balancing the CPU load
>> or the memory usage of nodes. weights apply to the load imbalance, both
>> automatic rebalancing methods and the selection of a node to start or
>> recover a resource on
>>
>> without configured weights, the TOPSIS method keeps favoring memory
>> usage 5 times over CPU load. if TOPSIS is the automatic rebalancing
>> method, pass weights of 1:5 in that case, so that the node imbalance is
>> weighted the same way and reflects what the TOPSIS method balances. this
>> changes the behavior for existing setups using the TOPSIS method: after
>> upgrading, their load imbalance is dominated by memory usage. setups
>> using the bruteforce method keep the unweighted load imbalance
>
> The "this changes the behavior for existing setups..." should come first
> here, because this is more the important part, because users essentially
> cannot set the weights before upgrading. The rest should go after it.

'pass weights of 1:5 in that case' is not addressed at users and the
part before 'this changes existing behavior [...]' is what 'this' refers
to, which apparently seems to be misleading or confusing, sorry for that

just swapping the order of sentences, however, is even more confusing
imo

I'll just rewrite the entire paragraph smh, so something along the lines
of 'this changes existing behavior [...]' comes first

>
> I just wonder whether this could cause the load balancer to make wildly
> different rebalancing decisions... The only test case that changes below
> for the TOPSIS method shows that for that particular test case the
> now weighted imbalance value is dampened... But is that true for most
> cases so it doesn't cause unwanted behavioral changes after upgrading?
>

I might be wrong but imo it's hard to make generalizations here

I suppose by 'dampened' you refer to the fact that the imbalance value
decreased, right?

if so, the value is dampened for this very test case, because CPU load
alone (1:0) is clearly more imbalanced (0.76) than memory usage (0.42)
alone (0:1) 

hence, weighting memory usage 5 times more than CPU load dampens the
imbalance value here

I guess 'unwanted behavioral changes after upgrading' can go either way:
the imbalance value is *seemingly* too low or to high now... it will
most likely not stay the same, but as a matter of fact it can, e.g.: 3
nodes with cpu=[0.6, 0.2, 0.1] and mem=[0.15,0.35,0.4] where imbalance
results in 12.73% for both 1:1 and 1:5, due to the covariance cancellation
effect

'seemingly' is the key point here, the imposed changed on how the
imbalance computation prioritizes resources can be (A) welcomed, (B)
refused or (C) even go unnoticed (if the effect is neglectable). either
way, the only thing that's guaranteed is that the weights used are
consistent with the weights of criteria used for ranking migration
candidates. in other words, the configured weights must consistently
play into how we quantify imbalance and how qualify the best migration
candidates

weighting resources differently when qualifying migration candidates and
quantifying load imbalance is not an option; it has to be consistent.
so, in case of A or B, re-adjust the weights accordingly. in case of C,
there is no problem, anyway, I guess

> One thing that comes to my mind, is that the dampened imbalance value in
> the default setting for TOPSIS would make the threshold trigger load
> balancing migrations later than before, no?
>

I don't know, what if a cluster is rather memory-heavy than cpu-heavy?

[snip]

>> diff --git a/src/PVE/HA/Manager.pm b/src/PVE/HA/Manager.pm
>> index 7de8781..3db5402 100644
>> --- a/src/PVE/HA/Manager.pm
>> +++ b/src/PVE/HA/Manager.pm
>> @@ -174,6 +174,39 @@ sub update_crs_settings {
>>          0.1,
>>      );
>>  
>> +    my ($cpu_weight, $mem_weight) = $crs_cfg->@{qw(ha-cpu-weight ha-mem-weight)};
>> +    my $weights_configured = defined($cpu_weight) || defined($mem_weight);
>> +    # the legacy TOPSIS criteria favor memory usage 5 times over CPU load by default, weigh the node
>> +    # load the same way, so that the imbalance reflects what the TOPSIS method balances
>> +    my $use_legacy_topsis_weights = !$weights_configured && $auto_rebalance->{method} eq 'topsis';
>> +
>> +    $self->update_crs_option('ha-cpu-weight', \$crs->{cpu_weight}, $cpu_weight, 1);
>> +    $self->update_crs_option(
>> +        'ha-mem-weight',
>> +        \$crs->{mem_weight},
>> +        $mem_weight,
>> +        $use_legacy_topsis_weights ? 5 : 1,
>> +    );
>> +
>> +    my $scheduler_options;
>> +    my $all_weights_zero = 0;
>> +    if (!$crs->{cpu_weight} && !$crs->{mem_weight}) {
>> +        # no resource would contribute to the node load, so there is nothing to balance; keep
>> +        # the default weights for selecting nodes to start or recover resources on
>> +        $haenv->log(
>> +            'warning',
>> +            "all CRS weights are set to 0, ignoring them and skipping automatic rebalancing",
>> +        ) if !$crs->{all_weights_zero};
>> +        $all_weights_zero = 1;
>> +    } elsif ($weights_configured || $use_legacy_topsis_weights) {
>> +        $scheduler_options = {
>> +            'cpu-weight' => $crs->{cpu_weight},
>> +            'mem-weight' => $crs->{mem_weight},
>> +        };
>> +    }
>> +    $crs->{scheduler_options} = $scheduler_options;
>> +    $crs->{all_weights_zero} = $all_weights_zero;
>
> nit: the relevant parts should get a
>
> # FIXME MAJOR VERSION: ...
>
> because the complexity of holding backwards compatible options here
> should be removed then to reduce maintaining unnecessary complexity
> here in the future.
>

ack

> Maybe we can even pivot both 'bruteforce' and 'topsis' having 1:1
> weights from the next major version on, so that the behavior is less
> complex to explain to (and understand by) new users as well.

+1

[snip]

>> diff --git a/src/PVE/HA/Usage/Dynamic.pm b/src/PVE/HA/Usage/Dynamic.pm
>> index 76d0fea..0da6115 100644
>> --- a/src/PVE/HA/Usage/Dynamic.pm
>> +++ b/src/PVE/HA/Usage/Dynamic.pm
>> @@ -9,12 +9,14 @@ use PVE::RS::ResourceScheduling::Dynamic;
>>  use base qw(PVE::HA::Usage);
>>  
>>  sub new {
>> -    my ($class, $haenv, $service_stats) = @_;
>> +    my ($class, $haenv, $service_stats, $scheduler_options) = @_;
>>  
>>      my $node_stats = eval { $haenv->get_dynamic_node_stats() };
>>      die "did not get dynamic node usage information - $@" if $@;
>>  
>> -    my $scheduler = eval { PVE::RS::ResourceScheduling::Dynamic->new() };
>> +    # only pass options if there are any, so that older versions of the bindings still work
>> +    my @args = defined($scheduler_options) ? ($scheduler_options) : ();
>> +    my $scheduler = eval { PVE::RS::ResourceScheduling::Dynamic->new(@args) };
>
> nit: could also be dropped in a major version, because the Option<...>
>      could probably be dropped safely in the future to have less logic
>      for this here
>

ack

>>      die "unable to initialize dynamic scheduling - $@" if $@;
>>  
>>      return bless {
>> diff --git a/src/PVE/HA/Usage/Static.pm b/src/PVE/HA/Usage/Static.pm
>> index e67d5f5..9b91ba6 100644
>> --- a/src/PVE/HA/Usage/Static.pm
>> +++ b/src/PVE/HA/Usage/Static.pm
>> @@ -9,12 +9,14 @@ use PVE::RS::ResourceScheduling::Static;
>>  use base qw(PVE::HA::Usage);
>>  
>>  sub new {
>> -    my ($class, $haenv, $service_stats) = @_;
>> +    my ($class, $haenv, $service_stats, $scheduler_options) = @_;
>>  
>>      my $node_stats = eval { $haenv->get_static_node_stats() };
>>      die "did not get static node usage information - $@" if $@;
>>  
>> -    my $scheduler = eval { PVE::RS::ResourceScheduling::Static->new(); };
>> +    # only pass options if there are any, so that older versions of the bindings still work
>> +    my @args = defined($scheduler_options) ? ($scheduler_options) : ();
>> +    my $scheduler = eval { PVE::RS::ResourceScheduling::Static->new(@args) };
>
> same here
>

ack

[snip]




  reply	other threads:[~2026-11-23 14:00 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12  9:44 [RFC PATCH-SERIES cluster/ha-manager/manager/proxmox{,-perl-rs} v2 00/19] fix #7993: implement weighted crs load balancing Dominik Rusovac
2026-11-12  9:44 ` [PATCH proxmox v2 01/19] resource-scheduling: fix typos Dominik Rusovac
2026-11-19 12:27   ` Daniel Kral
2026-11-12  9:44 ` [PATCH proxmox v2 02/19] resource-scheduling: scheduler: refine score_* docs Dominik Rusovac
2026-11-19 12:27   ` Daniel Kral
2026-11-19 12:47     ` Dominik Rusovac
2026-11-12  9:44 ` [PATCH proxmox v2 03/19] resource-scheduling: scheduler: abstract post-migration stats logic Dominik Rusovac
2026-11-19 12:28   ` Daniel Kral
2026-11-19 12:47     ` Dominik Rusovac
2026-11-12  9:44 ` [PATCH proxmox v2 04/19] fix #7993: resource-scheduling: node: add weighted node load Dominik Rusovac
2026-11-19 12:28   ` Daniel Kral
2026-11-19 12:50     ` Dominik Rusovac
2026-11-12  9:44 ` [PATCH proxmox v2 05/19] resource-scheduling: scheduler: make imbalance with candidate public Dominik Rusovac
2026-11-19 12:41   ` Daniel Kral
2026-11-19 12:52     ` Dominik Rusovac
2026-11-12  9:44 ` [PATCH proxmox v2 06/19] fix #7993: resource-scheduling: scheduler: add weights Dominik Rusovac
2026-11-19 12:40   ` Daniel Kral
2026-11-19 13:52     ` Dominik Rusovac
2026-11-12  9:44 ` [PATCH proxmox v2 07/19] workspace,resource-scheduling: add proptest as dev-dependency Dominik Rusovac
2026-11-12  9:44 ` [PATCH proxmox v2 08/19] resource-scheduling: scheduler: add property tests for weights Dominik Rusovac
2026-11-12  9:44 ` [PATCH proxmox-perl-rs v2 09/19] fix #7993: pve-rs: resource-scheduling: add scheduler options Dominik Rusovac
2026-11-19 12:45   ` Daniel Kral
2026-11-19 13:28     ` Dominik Rusovac
2026-11-12  9:44 ` [PATCH pve-cluster v2 10/19] fix #7993: datacenter config: ad ha-{cpu,mem}-weight crs options Dominik Rusovac
2026-11-20  8:43   ` Daniel Kral
2026-11-20 10:05     ` Dominik Rusovac
2026-11-12  9:44 ` [PATCH pve-manager v2 11/19] ui: form: crs options: make fine-tuning options advanced Dominik Rusovac
2026-11-20 13:37   ` Daniel Kral
2026-11-20 13:55     ` Dominik Rusovac
2026-11-12  9:44 ` [PATCH pve-manager v2 12/19] fix #7993: ui: form: crs options: add weights Dominik Rusovac
2026-11-20 13:35   ` Daniel Kral
2026-11-20 13:49     ` Dominik Rusovac
2026-11-12  9:44 ` [PATCH pve-ha-manager v2 13/19] manager: remove obsolete argument Dominik Rusovac
2026-11-12  9:44 ` [PATCH pve-ha-manager v2 14/19] manager: rename update_crs_scheduler_mod to update_crs_settings Dominik Rusovac
2026-11-20 13:39   ` Daniel Kral
2026-11-12  9:44 ` [PATCH pve-ha-manager v2 15/19] manager: factor out crs option update helper Dominik Rusovac
2026-11-20 13:46   ` Daniel Kral
2026-11-20 14:02     ` Dominik Rusovac
2026-11-12  9:44 ` [PATCH pve-ha-manager v2 16/19] manager: log changes to crs settings Dominik Rusovac
2026-11-20 13:54   ` Daniel Kral
2026-11-12  9:44 ` [PATCH pve-ha-manager v2 17/19] sim: hardware: allow changing datacenter settings at runtime Dominik Rusovac
2026-11-12  9:44 ` [PATCH pve-ha-manager v2 18/19] fix #7993: manager,usage: use weights for static and dynamic mode Dominik Rusovac
2026-11-23 12:45   ` Daniel Kral
2026-11-23 14:00     ` Dominik Rusovac [this message]
2026-11-12  9:44 ` [PATCH pve-ha-manager v2 19/19] test: add automatic rebalancing test cases with weights Dominik Rusovac

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DN2N86N8FNQC.2U5BJTA1QQKI4@proxmox.com \
    --to=d.rusovac@proxmox.com \
    --cc=d.kral@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal