Files
Balazs Gibizer 3457ecd69a Check overall capacity before generating candidates
This is a performance optimization for an edge case where
* We have wide, symmetric provider trees. E.g. 10+ children RPs within a
  tree providing the same type of resources
* A GET allocation_candidates request that asks for 10+ request groups
  of such resources
* But the tree has less available resources left than the number of
  requested groups by a small amount. I.e. the request almost fits but
  does not.

In this case even the wide tree optimized allocation candidate
generation algorithm produces a lot of partially valid candidates before
it finds that the last (couple of) group in the request cannot be
fulfilled. This takes excessive time.

This patch adds a check before the allocation candidate generation
algorithm runs. This check runs on each tree. It compares the total
requested resources per resource class with the total available
resources per resource class in the tree and filters out the tree if it
finds that the overall pool of resources from the tree is not enough.

As testing shows that the cost of this pre-check is reasonable for the
simple cases too the pre-check is enabled unconditionally. However there
is a small optimization in the pre-check. If a resource class only
requested in a single request group then it is ignored as our edge case
is already eliminated when that group individually failed to be
fulfilled. As an extension if the request has no resource class
used in multiple groups, or only have a single group, then the pre-check
is a no-op.

Closes-Bug: #2160721
Signed-off-by: Balazs Gibizer <gibi@redhat.com>
Change-Id: I9bac03b0162009cdcea024f091bf63b177eaa279
2026-07-24 20:33:07 +02:00
..
2019-03-13 21:24:34 +00:00
2024-07-04 11:13:36 +01:00