core: optimize AllocsFit to minimize calculation #9284
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
AllocsFit is called from the plan applier and binpacking iterator to
ensure planned/proposed allocs fit on a node. While it always compares
mem/cpu resources, it does not always need to check devices and
networks.
Plan Applier
Before this change the plan applier would always check devices and
networks for collisions.
After this change the plan applier will only checks devices and
networks for collisions if the plan's job contains devices and
networks. There's no possibility of a collision if there are no new
device or network reservations.
Binpack Iterator
Before this change the binpack iterator would never check ports
or devices because those feasibility checks are handled elsewhere.
Bandwidth was checked but hardcoded to pass since Nomad 0.12.
The behavior has not changed, but the code is much cleaner. Before a
network index would be passed to AllocsFit, but only its bandwidth
would be checked. Since bandwidth is deprecated, this check was a
noop. All of that code is removed so it no longer appears that
AllocsFit is checking for network collisions when it does not.
TODO