28 Commits

Author SHA1 Message Date
5625354acc resource-scheduling: bump version to 1.0.0-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-05-31 16:04:25 +02:00
e85ab755f4 resource-scheduling: inherit meat info, dependencies and buildsys from workspace
Like in the other crates from this workspaces

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-05-31 16:03:02 +02:00
96cba26c2d resource-scheduling: replace lazy_static crate with std lib's LazyLock
Might be also a LazyCell, as this is currently mainly used in Perl,
where we cannot really use threads anyway, but never say never and it
might be used in pure rust too someday; besides, it can be changed if
needed.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-05-31 16:02:26 +02:00
966f653e62 resource-scheduling: refresh d/control for initial Debian Trixie versions
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-05-31 16:02:26 +02:00
af508c0e8e buildsys: derive upload dist automatically
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-05-31 16:02:25 +02:00
74eaa2dd41 bump version to 0.3.0-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-05-31 16:02:25 +02:00
a361cab793 buildsys: add sbuild target for convenience
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-05-31 16:02:25 +02:00
3ae85d2d5a buildsys: drop no-pre-clean flags for buildpackage invocation
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-05-31 16:02:25 +02:00
7a7be8c38c buildsys: cleanup and expand clean target
also remove *.build files (generated by sbuild)

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-05-31 16:02:25 +02:00
f100cb1c2c bump version to 0.2.1-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-05-31 16:02:25 +02:00
a08e84b838 pve static: add one to avoid boosting tiny relative differences
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 <f.ebner@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-05-31 16:02:25 +02:00
01d0da2694 bump version to 0.2.0-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-05-31 16:02:25 +02:00
843edb67ff pve ha: fix typo in comment
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-05-31 16:02:25 +02:00
02be4dabe4 pve ha: fix scoring issue when a node is overcommitted compared to others
When nodes have different stats, the sum of percentage values will be
different for different alternatives, so the linear average is enough.
But when nodes have the same stats, this is not the case, the sum will
be the same, thus the average won't influence the scoring. If there is
an already overcommitted node, all alternatives besides the already
overcommitted node would be scored the same.

To fix it, use the squares of percentages instead, where more evenly
distributed usage across nodes will lead to a smaller value and thus
better scoring.

It's not really necessary to divide by length or take the sqrt, but it
seemed nicer to have something that would give 1.0 if all inputs are
1.0.

Reported-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-05-31 16:02:25 +02:00
201bd80fc6 Cargo.toml: remove lib section
as this is just the default anyway

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-05-31 16:02:25 +02:00
4e875256ff comment on lack of optimization of array::from_fn
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-05-31 16:02:25 +02:00
a2bbe17cc7 avoid some more allocations
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-05-31 16:02:25 +02:00
e3abad14c0 avoid extra allocation in rank_alternatives
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-05-31 16:02:25 +02:00
e5af38b400 shorten code
this now wouldn't cause the weigh() lines to exceed 100
chars ;-)

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-05-31 16:02:25 +02:00
4c7e3587c7 simplify weighing
We already use functions that take or return the full [T; N]
array, so let's just do the same here, it's a bit shorter
this way.

If we get worried about large values we should implement
versions with `&mut [T; N]` consistently for all math
functions.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-05-31 16:02:25 +02:00
88e8c3fb14 simplifications
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-05-31 16:02:25 +02:00
3a45b25efc drop Topsis prefix of all the types in topsis::
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-05-31 16:02:25 +02:00
8bf1761840 make ideal_alternatives a method of IdealAlternatives
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-05-31 16:02:25 +02:00
8398e38693 reorder impl blocks
so they're next to their types

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-05-31 16:02:25 +02:00
021c0dcfa7 add criteria_struct helper macro
This enforces the order in the Criteria and its From into
the Matrix entry.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-05-31 16:02:25 +02:00
53fa2b86af add Debian packaging
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-05-31 16:02:25 +02:00
2b325aa5c7 add pve_static module
Models usage of guests and nodes, and allows scoring nodes on which to
start a new service via TOPSIS. For this scoring, each node in turn is
considered as if the service was already running on it.

CPU and memory usage are used as criteria, with memory being weighted
much more, because it's a truly limited resource. For both, CPU and
memory, highest usage among nodes (weighted more, as ideally no node
should be overcommited) and average usage of all nodes (to still be
able to distinguish in case there already is a more highly commited
node) are considered.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-05-31 16:02:25 +02:00
d23de546cf initial commit
Implement the TOPSIS[0] algorithm to score multi-valued alternatives
according to a given set of weighted criteria.

The number of alternatives cannot be known at compile time, but the
number of criteria should be (a given module using the topsis module
should have one (or more) fixed sets of criteria). Therefore, the
TopsisMatrix is implemented as a Vec of N_CRITERIA-sized arrays.

Compared to the description in [0] the weighing of the matrix
according to the weights of the criteria only happens during distance
calculation to the idealized alternatives. It turned out more natural
like that, because the matrix doesn't need to be mutable.

[0]: https://en.wikipedia.org/wiki/TOPSIS

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-05-31 16:02:25 +02:00