Commit Graph

25 Commits

Author SHA1 Message Date
Thomas Lamprecht
09c43554fa buildsys: derive upload dist automatically
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-05-08 14:59:20 +02:00
Thomas Lamprecht
ba581d9832 bump version to 0.3.0-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-05-08 14:56:15 +02:00
Thomas Lamprecht
235888a390 buildsys: add sbuild target for convenience
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-05-08 14:49:15 +02:00
Thomas Lamprecht
c5d35583ae buildsys: drop no-pre-clean flags for buildpackage invocation
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-05-08 14:48:54 +02:00
Thomas Lamprecht
63ae666b4e buildsys: cleanup and expand clean target
also remove *.build files (generated by sbuild)

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-05-08 14:48:01 +02:00
Thomas Lamprecht
4b5e94a1cb bump version to 0.2.1-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-03-21 17:56:41 +01:00
Fiona Ebner
40e3f47b8e 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>
2023-03-21 17:53:07 +01:00
Thomas Lamprecht
a6583c7e28 bump version to 0.2.0-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-03-21 14:54:34 +01:00
Fiona Ebner
8d7c1922b2 pve ha: fix typo in comment
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2023-03-21 14:52:29 +01:00
Fiona Ebner
cb5a242b93 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>
2023-03-21 14:52:29 +01:00
Wolfgang Bumiller
582cf066d5 bump version to 0.1.0-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-11-15 11:08:33 +01:00
Wolfgang Bumiller
3623ff42f5 Cargo.toml: remove lib section
as this is just the default anyway

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-11-15 11:08:04 +01:00
Wolfgang Bumiller
ca425a6543 comment on lack of optimization of array::from_fn
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-11-11 13:50:42 +01:00
Wolfgang Bumiller
871a56a2c4 avoid some more allocations
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-11-11 13:50:42 +01:00
Wolfgang Bumiller
f5ea755fb7 avoid extra allocation in rank_alternatives
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-11-11 13:50:42 +01:00
Wolfgang Bumiller
0cad3884f9 shorten code
this now wouldn't cause the weigh() lines to exceed 100
chars ;-)

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-11-11 13:50:42 +01:00
Wolfgang Bumiller
0223ef43c1 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>
2022-11-11 13:50:42 +01:00
Wolfgang Bumiller
a05496e3ff simplifications
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-11-11 13:50:42 +01:00
Wolfgang Bumiller
5a50196a13 drop Topsis prefix of all the types in topsis::
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-11-11 13:50:42 +01:00
Wolfgang Bumiller
4ac19a0016 make ideal_alternatives a method of IdealAlternatives
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-11-11 13:50:42 +01:00
Wolfgang Bumiller
c83c8887c8 reorder impl blocks
so they're next to their types

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-11-11 13:50:42 +01:00
Wolfgang Bumiller
060a1ec460 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>
2022-11-11 13:50:42 +01:00
Fiona Ebner
d48a152a46 add Debian packaging
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2022-11-11 08:38:03 +01:00
Fiona Ebner
7faeaccdf3 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>
2022-11-11 08:37:58 +01:00
Fiona Ebner
06484e0ef9 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>
2022-11-11 08:37:48 +01:00